简体   繁体   中英

Automation Testing using winium

If multiple elements have got the same name and there is no unique id for elements. How do we proceed automation testing using winium?

Is it possible to use clickable point coordinates for automation?

If you know that the position of the element you're interested in will not change, then you can first get a list of all the elements that match the name you are identifying with. Iterate through the list and print out the coordinates. Then determine which one is the one you want and use those coordinates for clicking on the element. I believe (0,0) is the top left corner of the screen.

Sometimes I've found that I can identify an element with the same name as other elements by finding its parent or child elements. This will only work if the parent/child elements differ from the other elements that had the same name. It's annoying but sometimes I've had to find a unique child element, then get the parent element 2 levels above that, for example. Because that child element was the only unique identifier.

You can proceed by using XPath locators to test using winium. XPath allows you to build queries for elements you want, and use different properties of elements that UISpy uses to identify elements. However, this might need you to write XPath in a manner that reduces search scope on every level.

I found this example somewhere on the web. This is more about narrowing the approach.

For example / [@AutomationId='MyMainWindow']// [@Name='Add Event'] will be preferable over //*[@Name='Add Event'] as the former has much more limited scope on the top level than the latter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM