[英]iOS Automation Tests: buttons' Label not recognized by Instruments
I'm currently working on an automation script (JavaScript) for an iOS app. 我目前正在为iOS应用程序开发自动化脚本(JavaScript)。 I'm not a programmer, just a tester who wants to seek bugs. 我不是程序员,只是想要寻找bug的测试人员。
Software concerned: Xcode, Instruments . 涉及的软件: Xcode,Instruments 。
Here is the problem: there are buttons in my application that had no name, which is important for automated tests, so I gave them a Label in the Accessibility field of Xcode. 问题是:我的应用程序中有按钮没有名称,这对自动化测试很重要,所以我在Xcode的Accessibility字段中给了它们一个Label。 But Instruments still doesn't recognize the name of the buttons. 但是仪器仍然无法识别按钮的名称。
eg: What I want, but doesn't work: 例如:我想要什么,但不起作用:
target.frontMostApp().mainWindow().scrollViews()[2].buttons()["Settings"].tap();
What I don't want, but works: 我不想要的,但有效:
target.frontMostApp().mainWindow().scrollViews()[2].buttons()[1].tap();
This is just one of many situations I've encountered. 这只是我遇到的许多情况之一。 I chose a simple one and it could seem trivial, but some others are really problematic. 我选择了一个简单的,它看似微不足道,但其他一些确实存在问题。
Any idea how to fix this? 知道如何解决这个问题吗?
Do you create the code by typing it, or do you capture it? 您是通过键入来创建代码,还是捕获它?
If you havn't captured it: you can do that by using that small record button in the JavaScript editor. 如果您没有捕获它:您可以通过在JavaScript编辑器中使用该小记录按钮来实现。 After capturing, Instruments shows you the code, that would automate the actions you did "by hand". 捕获后,Instruments会向您显示代码,这将自动执行您“手动”执行的操作。 Then you can find out, if there is a different way to adress the button. 然后你可以找出,如果有不同的方式来按下按钮。 This way you can find out how to trigger your button I havn't set up my GUI elements with the acessibility properties, because this way I can find out how to trigger the elements. 通过这种方式,您可以了解如何触发按钮我没有使用acessibility属性设置我的GUI元素,因为这样我可以找到如何触发元素。
It sometimes takes a few tries to get things running. 它有时需要几次尝试才能运行。
Also, if an animation is applied when the screen is changing, a delay is needed before you can trigger the next GUI event: 此外,如果在屏幕更改时应用动画,则在触发下一个GUI事件之前需要延迟:
target.delay(1);
This creates a delay of 1 second until the next event is fired. 这会产生1秒的延迟,直到触发下一个事件。
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.