I just want to access a xpath. But when I'm search this in inspect menu it finding 5 result. I want to access one of them not 5. How can I do it with index number? like...
xpath = "//a[@role='button']" # 5 elements available with this xpath
modified_xpath = "//a[@role='button'][2]" # I'm trying with the index number.
driver.find_element_by_xpath(modified_xpath).click() # But It's not working.
It's not working!
You can do it like this code--
xpath = "//a[@role='button']"
xpaths = driver.find_elements_by_xpath(xpath)
xpaths[2].click()
Hope it will work.
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