Home > OS >  selenium xpath unable to locate text on web page
selenium xpath unable to locate text on web page

Time:09-21

I am trying to click on the Inclusive button within my account on the IMDB website as illustrated by the image further below.

I have tried various combinations of selenium xpath values and have googled various links to attempt to achieve this including enter image description here

CodePudding user response:

Your xpath seems wrong. Use the below xpath to click on the Inclusive button

//div[@role='button' and @data-titleinlist='false'][contains(., 'Inclusive')]

So your code will be like

xpath = "//div[@role='button' and @data-titleinlist='false'][contains(., 'Inclusive')]"
button3 = driver.find_element(By.XPATH, xpath)
driver.execute_script("arguments[0].click();", button3)

Please provide enough wait to element to be visible or clickable.

you can use below xpath as well.

//div[@class='sc-1aecbe70-0 dpbfLr']//div[@role='button'][contains(., 'Inclusive')]

You can use that as well.

//div[@class='sc-1aecbe70-0 dpbfLr']//div[@role='button' and @data-titleinlist='false'][contains(., 'Inclusive')]
  • Related