Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium webdriver 如何使用appium在android混合应用程序上查找元素_Selenium Webdriver_Automated Tests_Ui Automation_Appium - Fatal编程技术网

Selenium webdriver 如何使用appium在android混合应用程序上查找元素

Selenium webdriver 如何使用appium在android混合应用程序上查找元素,selenium-webdriver,automated-tests,ui-automation,appium,Selenium Webdriver,Automated Tests,Ui Automation,Appium,我正在尝试使用Appium测试混合应用程序。 我无法使用Appiuminspector或uiautomatorviewer检查ID。它只显示应用程序的一个类。 我试图使用web应用程序检查id元素,但它不起作用。 所以我的问题是,找到/获取应用程序元素的另一种方法是什么 编辑: xpath没有帮助。这是我的密码: public void findButton() { driver.findElement(By.xpath("//html/body/div[5]/div/div/d

我正在尝试使用Appium测试混合应用程序。 我无法使用
Appium
inspector或
uiautomatorviewer
检查ID。它只显示应用程序的一个类。 我试图使用web应用程序检查id元素,但它不起作用。 所以我的问题是,找到/获取应用程序元素的另一种方法是什么

编辑: xpath没有帮助。这是我的密码:

public void findButton() {
        driver.findElement(By.xpath("//html/body/div[5]/div/div/div[1]/div[1]/div[3]/div[1]/div[2]/div[3]/div[2]"));
}

Web应用程序通常没有我们期望使用的所有元素。相反,您可以使用类名/索引,过滤它并将其用作xpath。

步骤1-需要将控件从本机应用程序移动到Web视图(其中使用webview呈现页面)

步骤2-通过USB将设备连接到系统,并使用URL打开浏览器chrome://inspect

步骤3-识别特定元素将视图更改为 网络视图

它会将上下文打印为本机,
WEBVIEW_com.xxx.yyy.zzzz
,然后 为了使混合应用程序自动化,必须将上下文更改为WEBVIEW

eg: driver.context("WEBVIEW_com.xxx.yyy.zzzz");

driver.context-->它将切换上下文

您的应用程序是用哪种技术开发的?
Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {

System.out.println(contextNames);

}
driver.context("WEBVIEW_com.xxx.yyy.zzzz");
eg: driver.context("WEBVIEW_com.xxx.yyy.zzzz");