在Sauce Labs上运行Appium测试时出现无效的选择器异常

时间:2016-05-16 10:43:00

标签: android xpath appium ui-automation saucelabs

我使用的xpath适用于Android应用:

//android.widget.EditText[contains(@resource-id,'etPass')]

当我在真实设备或VM上本地运行测试时,此xpath工作正常。

但是当我在Sauce Labs上运行相同的测试时,它会给我一个无效的选择器异常。

org.openqa.selenium.InvalidSelectorException: 
An error occurred while searching for an element by XPath. (WARNING: 
The server did not provide any stacktrace information)
Command duration or timeout: 88 milliseconds
For documentation on this error, please visit: 
http://seleniumhq.org/exceptions/invalid_selector_exception.html

当我使用带有@text的xpath代替@resource-id时,它可以正常工作。为什么Sauce Labs不会将@resource-id识别为查找xpath的有效属性?

以下是uiautomatorviewer with xml

的屏幕截图

UiAutomatorViewer screenshot

1 个答案:

答案 0 :(得分:0)

正确的方法是使用它:

//android.widget.EditText[contains(@id,'etPass')] //resource-id is not a recognised attribute for selection

此外,如果您需要特定于使用x-path选择单个元素:

//android.widget.EditText[@id='etPass'] // = ensures the value match for specified attribute
相关问题