HTML
<span class="menu-text">Download App</span>
my code to locate the element
driver.find_element_by_css_selector("//span[contains(text(),'App')]")
or
driver.find_element_by_css_selector("//span[contains(.,'App')]")
when I run it, an exception reported:
selenium.common.exceptions.InvalidSelectorException: Message: Given css selector expression "//span[contains(text(),'App')]" is invalid: InvalidSelectorError: '//span[contains(text(),'App')]' is not a valid selector: "//span[contains(text(),'App')]"
Since your using a xpath expression, use driver.find_element_by_xpath instead
driver.find_element_by_xpath("//span[contains(text(),'App')]")
hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With