-1

Hi I'm trying to use selenium to click on some element on my web app, which i gave senchatest locator "senchatest=mainMenu_plus" (because of random ID's) I have script in Python

self.addProperty = self.browser.find_element_by_id("//*[@senchatest='senchatest=mainMenu_plus']//")

the output is still

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="//*[@senchatest='senchatest=mainMenu_plus']//"]

no matter if i use .find_element_by_id or xpath

can you please help?

matsi
  • 27
  • 5

2 Answers2

0

You are using browser.find_element_by_id(expression) on an XPATH expression. If that is a unique locator based on that attribute, you should be able to use

self.addProperty = self.browser.find_element_by_xpath("//*[@senchatest='mainMenu_plus']")

Does that work?

C. Peck
  • 3,641
  • 3
  • 19
  • 36
0

From the HTML shared and the locator that you have been trying looks not correct. try changing it to xpath like this :

//div[@senchatest='mainMenu_plus']

and use it like this :

self.browser.find_element_by_xpath("//div[@senchatest='mainMenu_plus']
")
cruisepandey
  • 28,520
  • 6
  • 20
  • 38