Finding and interacting with elements
Appium supports a subset of the WebDriver locator strategies such as:
Appium支持WebDriver定位策略的子集例如:
- find by “class” (i.e., ui component type)
- find by “xpath” (i.e., an abstract representation of a path to an element, with certain constraints)
You can see a list of them in Selector Strategies
Appium additionally supports some of the Mobile JSON Wire Protocol
locator strategies
Appium还支持部分'Mobile JSON Wire Protocol'
的定位策略
ios predicate string
: a string corresponding to a recursive element search using the iOS Predicate (iOS 10.0 and above)ios uiautomation
for iOS 9.3 and below
android uiautomator
: a string corresponding to a recursive element search using the UiAutomator Api (Android-only)android datamatcher
: a string corresponding to an Espresso DataMatcher json (Android-only)accessibility id
: a string corresponding to a recursive element search using the Id/Name that the native Accessibility options utilize.
Finally, Appium supports several additional experimental locator strategies:
最后,Appium支持集中额外的实验定位策略:
image
: a string corresponding to a base64-encoded version of an image which should be used by Appium as a template to find a matching screen region, which can then be tapped as if it were an element. For more information on this locator strategy, see the Finding Image Elements doc.custom
: a string which will be sent to an element finding plugin registered via thecustomFindModules
capability. For more information on this strategy, check out the Element Finding Plugin docs.
Issues
问题
There’s a known issue with table cell elements becoming invalidated before there’s time to interact with them. We’re working on a fix
一个已知的问题是
在它的时间与他们交互之前表格单元格元素失效.
我们正在解决.
Using Appium Desktop To Locate Elements
使用Appium Desktop定位元素
Appium provides you with a neat tool that allows you to find the the elements you’re looking for. With Appium Desktop you can find any element and its locators by either clicking the element on the screenshot image, or locating it in the source tree.
Appium为你提供一个简介的工具去寻找你要找到的元素.
使用Appium Desktop你可以查找任何元素并通过点击屏幕截图上的元素在源代码树进行定位找它的定位器
Overview
Appium Desktop has a simple layout, complete with a source tree, a screenshot, and record and refresh buttons, and interaction tools.
Appium Desktop有一个简单的布局,
完整的代码树,
截图,
及录制刷新按钮
及交互工具
Example
After launching Appium Desktop and starting a session, you can locate any element in the source. In this test, I’m looking for the accessibility id of the “Compute Sum” button.
启动Appium Desktop并启动会话,
你可以定位任何元素.
在这个测试中,
我正在找'Compute Sum'按钮的可访性id
To find the accessibility id of this button, I click the “Compute Sum” button in the screenshot. The element is then highlighted in the source tree. In the panel on the right, I can see the accessibility id.
为寻找此按钮的accessibility id,
我在屏幕中点击'Compute Sum'按钮.
这个元素在代码树中是高亮突出的.
在面板上的右边,
我可以看到'accessibility id'.
REPL
A REPL is a simple interactive language shell. You can invoke various command interactively. It will help you to make sure your scenarios interactively with Appium server.
REAL是一个简单的交互语言shell.
你可以提出各种交互命令.
它将会确保你的Appium server与场景交互.
Appium Ruby Console
WebDriverIO with debug mode