Home > Mobile >  What approach we should use if we didnt find any locators [closed]
What approach we should use if we didnt find any locators [closed]

Time:10-04

If there is no locators are available for a element in a webpage then what approach we should use?

For example, if we have button to be clicked but there is no locators are available for that element. How I will click that element?

I tried of using Sikuli, but need to know any other approach is there?

CodePudding user response:

Sikuli is the best option, sikuli can click any thing on the screen. but in you question, we can identify any element in the webpage by locators.

CodePudding user response:

Option 1: Absolute xpath Easy to get from browser https://i.stack.imgur.com/pM5qh.png. But even small changes on the web can crash test bcs used xpath won't be valid anymore.

Option 2: Relative xpath Probably best approach https://www.tutorialspoint.com/what-is-the-difference-between-relative-and-absolute-xpath-in-selenium. Combining with List<WebElement> elements = driver.findElements(By by) which returns empty list instead of NoSuchElementException and maybe even with child elements https://www.tutorialspoint.com/locating-child-nodes-of-webelements-in-selenium you can always have a nice stable working locator.

  • Related