I have a span
tag where we have a value 2 which keeps changing. I want to store this value in a variable either using javascript or playwright (a testing tool).
<span class="dynamic classname" data-testid="typography">2</span>
Note: Even class name is not constant.
const count = document.getElementByTagName('span');
which obviously doesn't work.
Using playwright:
const element = await page.locator('[data-testid="typography"]');
const count = await element.getAttraibute(element);
I'm new to javascript and playwright, any lead would be helpful.