pythonseleniumtestingkatalon

Senchatest locators, selenium can't find


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?


Solution

  • 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?