Luc
Luc

Reputation: 23

Copied full xpath still gives me NoSuchElementException Python Selenium

After copying the full xpath I still keep getting errors while trying to click the element. Any ideas on what I am doing wrong, here is the code:

driver.find_element_by_xpath("/html/body/div/div/div[1]/div[1]/div/div/main/div/div[1]/div/div[1]/div/div[1]/div[1]/button[2]").click()

EDIT: Probably not useful but whenever I press F12 to open the developer tools it clicks the button.

Upvotes: 0

Views: 185

Answers (1)

SeleniumBeginner
SeleniumBeginner

Reputation: 36

You can verify if the element locator is working properly , with some extensions for chrome and Firefox i.e Chropath and Firepath (Absolute path is not advisable). Coming to your issue, please verify the button properties.If direct click does not work,There are other classes like Actions and JavaScriptExecutor to perform clicks on elements . This should solve your issue.

Upvotes: 2

Related Questions