I'm trying to find an element with a specific nth index as a CSS expression.
How can I fix my code without changing the CSS expression?
try:
expect(self.page.locator('div[class="some-class"]:nth(3)')).\
to_be_visible(timeout=20000)
return True
except AssertionError:
return False
The error I get is:
{Error}DOMException: Failed to execute 'querySelectorAll' on 'Document': 'div[class="some-class"]:nth(3)' is not a valid selector.
Your locator should look like this. Replace ":" with ">>"
div[class="some-class"]>>nth=3