该元素出现在appium视图中,但不幸的是,该元素在自动化时似乎不可见。
private AndroidDriver driver;
String idOfCNIC = "com.tez.androidapp:id/imageViewNICDetails";
this.driver.findElement(By.id(idOfCNIC))`
以下是驱动程序初始化代码:
private static AndroidDriver driver;
public static AndroidDriver getDriver() {
if (driver == null) {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "920121cb3c7fc34a");
caps.setCapability("platformName", "Android");
caps.setCapability(CapabilityType.VERSION, "6.0.1");
caps.setCapability(CapabilityType.BROWSER_NAME, "Android");
caps.setCapability("app", "path_of_app");
(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
try {
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
return driver;
}
答案 0 :(得分:0)
您好,请使用以下版本的Appium Java客户端和Selenium:
另请尝试使用以下代码进行驱动程序初始化:
private static AndroidDriver<?> driver;
public static AndroidDriver getDriver() {
if (driver == null) {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "920121cb3c7fc34a");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME,"Appium ");
caps.setCapability(MobileCapabilityType.VERSION, "6.0.1");
caps.setCapability(MobileCapabilityType.APP, "path_of_app");
caps.setCapability("appWaitActivity", "*");
try {
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), caps);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
return driver;
}
我希望这能解决你的问题。谢谢!