Home > OS >  How to solve 'invalid locator' problem during "click a button problem" in Python
How to solve 'invalid locator' problem during "click a button problem" in Python

Time:11-05

I have a button that html is below

enter image description here

I tired the following code

Execute_Button = driver.find_element("xPath",'//button[text()="Execute "]')

But Python comes up with this error message. How to solve?

InvalidArgumentException: Message: invalid argument: invalid locator

CodePudding user response:

According to docs (locating elements), locating by xpath can be done using locator By.XPATH or 'xpath'. In your code you use 'xPath', which is invalid. To fix that simply change it to one of the two I mentioned, i.e.

Execute_Button = driver.find_element(By.XPATH,'//button[text()="Execute "]')

CodePudding user response:

browser.find_element_by_xpath('//button[text()="Execute "]').click()
  • Related