简体   繁体   English

iOS自动化测试:按钮'标签无法被仪器识别

[英]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.

相关问题 使用仪器从iOS自动化测试文件中进行的非同步调用 - Asynchrounous call from iOS automation test file using instruments IOS Automation:有没有办法“刷新”元素树(或者“仪器”认为它能够和不能访问的任何东西)? - IOS Automation: Is there a way to 'refresh' the Element Tree (Or whatever 'Instruments' thinks it can and cannot access)? 无法识别 JS 文件中的缓冲区(使用空手道框架进行 API 测试自动化) - Buffer in JS file isn't recognized (API tests automation with Karate Framework) 使用iOS的UIAutomation Instruments时,是否可以在两次测试之间保持我的应用程序打开? - When using UIAutomation Instruments for iOS is there a way to keep my app open between tests? 为什么Instruments UI Automation无法在我的设备上运行? - Why does Instruments UI Automation fail to run on my device? JavaScript-使用乐器在iOS中进行Python通信 - JavaScript - Python communication in iOS using Instruments iOS-如果仪器测试失败,请终止该应用 - IOS - Kill the app if a test fails in instruments 从iOS工具脚本调用Javascript - Call Javascript from iOS instruments script 生成带有标签的单选按钮 - Generating radio buttons with label Instruments:UI Automation:iPhone app - 如何使用 NSRect 的参数点击“null”按钮? - Instruments:UI Automation:iPhone app - how to tap “null” button using parameters of NSRect?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM