[英]Appium xpath attribute text
An Android 4.4.4
physical smart phone device is sitting on USB tether, ADB
enabled. Android 4.4.4
物理智能手机设备位于USB系绳上,启用了ADB
。 Attempts are being made to automate a hybrid android application on this device via Appium
(Java). 正在尝试通过Appium
(Java)在该设备上自动化混合Android应用程序。
We are experiencing trouble reconciling elemental discovery and access behavior. 我们在协调元素发现和访问行为方面遇到了麻烦。
For example: 例如:
List<WebElement> buttons = driver.findElements(By.xpath("//android.widget.Button[@text='Something']"));
System.out.println("Found " + buttons.size() + " buttons.");
for ( WebElement el : buttons ) {
System.out.println(el.getAttribute("text"));
}
One (1) button is discovered. 发现一(1)个按钮。 The button found clearly has a "text" attribute containing "Something". 找到的按钮清楚地具有包含“Something”的“text”属性。 However, when trying to print the contents of the "text" attribute the result is empty; 但是,在尝试打印“text”属性的内容时,结果为空; just a line return. 只是换行。
Additionally, when the .click();
另外,当.click();
method is invoked, the element "clicked" is NOT the element found. 调用方法,“clicked”元素不是找到的元素。 In fact, according to the UI xml of the app, the element clicked isn't even an android.widget.Button
. 事实上,根据应用程序的UI xml,单击的元素甚至不是android.widget.Button
。
Any ideas regarding what could be causing this unexpected behavior? 关于什么可能导致这种意外行为的任何想法?
Thanks in advance. 提前致谢。
As you are saying that you are automating a hybrid application so you have to switch context before perform any action like sendkeys
or click or tap. 正如您所说,您正在自动化混合应用程序,因此您必须在执行任何操作(如sendkeys
或单击或点击)之前切换上下文。 so refer to context switch tutorials and try. 所以请参考上下文切换教程并尝试。 Basically you are on native context and for hybrid app context
should be changed to webview
. 基本上,您使用的是本机上下文,混合应用程序context
应更改为webview
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.