简体   繁体   English

使用winium进行自动化测试

[英]Automation Testing using winium

If multiple elements have got the same name and there is no unique id for elements.如果多个元素具有相同的名称并且元素没有唯一的 id。 How do we proceed automation testing using winium?我们如何使用 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.我相信 (0,0) 是屏幕的左上角。

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.这很烦人,但有时我不得不找到一个唯一的子元素,然后让父元素比它高 2 级,例如。 Because that child element was the only unique identifier.因为该子元素是唯一的唯一标识符。

You can proceed by using XPath locators to test using winium.您可以继续使用 XPath 定位器来测试使用 winium。 XPath allows you to build queries for elements you want, and use different properties of elements that UISpy uses to identify elements. XPath 允许你为你想要的元素构建查询,并使用 UISpy 用来识别元素的元素的不同属性。 However, this might need you to write XPath in a manner that reduces search scope on every level.但是,这可能需要您以缩小每个级别的搜索范围的方式编写 XPath。

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.例如 / [@AutomationId='MyMainWindow']// [@Name='Add Event'] 比 //*[@Name='Add Event'] 更可取,因为前者在顶层的范围要有限得多比后者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用C#使用Winium进行桌面Windows应用程序自动化 - Desktop Windows Application automation using winium using c# 使用Winium驱动程序和C#向下滚动 - Scroll down using winium driver with c# 使用 C#、.net 和 TFS 进行自动化测试的可执行文件 - Executable file for automation testing using C#, .net and TFS 在Visual Studio中使用Selenium C#进行Web自动化测试与使用C#进行桌面应用自动化测试有何相似之处? - How similar is Web Automation testing using Selenium C# in Visual Studio to Desktop App Automation Testing using C#? 使用UI自动化进行单元测试 - Unit testing with UI automation 通信模块自动化测试 - Communication Module Automation Testing 没有自动化框架的WPF自动化测试? - WPF Automation Testing without Automation Framework? 使用 c# 自动化测试 Selenium - Automation testing Selenium with c# 可以使用Selenium Webdriver和C#完成Android App自动化测试吗? - Can Android App automation testing be done using selenium webdriver and C#? 我们如何仅使用C#而不使用任何第三方工具来进行UI自动化测试? - How can we do UI automation testing only using C# without any third party tool?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM