These two elements have the exact same attributes except for the text in the pseudo-element. Is there anyway I can click on the “Practical” element. I’ve tried the following to no avail:
driver.find_element(By.XPATH, "//div[contains(text(),'Practical')]").click() driver.find_element(By.XPATH, "//div[@class='v-tab']")[1].click()
Advertisement
Answer
Pseudo elements are not elements. So, that ::before
seems to be just a kind of text content of div
element.
I can’t give you tested answer since you didn’t share a link to the page you are working on, but I can suggest.
I’d try this:
driver.find_element(By.XPATH, "//div[@class='v-tab'][contains(.,'Practical')]")].click()
In case v-tab
class name and Practical
text content are unique enough it should work. Otherwise you will need to find nore unique locator.