class demo{
public AndroidDriver getAndroidDriver(String packageName){
VirtualPhone vp = new VirtualPhone();
Properties p = new Properties();
FileInputStream stream = null;
AndroidDriver androidDriver = null;
String fileName = String.format(".\src\main\java\com\g7\tools\%s.properties", packageName);
try {
stream = new FileInputStream(fileName);
p.load(stream);
String name = p.getProperty("name");
String udid = p.getProperty("udid");
String platformVersion = p.getProperty("platformVersion");
String appPackage = p.getProperty("appPackge");
String appActivity = p.getProperty("appActivity");
String url = p.getProperty("url");
vp.setDeviceName(name);
vp.setUdid(udid);
vp.setPlatformVersion(platformVersion);
vp.setAppPavckage(appPackage);
vp.setAppActivity(appActivity);
DesiredCapabilities dcap = vp.getVirtualEnvironment();
androidDriver = new AndroidDriver(new URL(url), dcap);
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
return androidDriver;
}
}
AndroidDriver ad = new demo().getAndroidDriver("App 包名")
Set contexts = ad.getContextHandles();
for(String context : contexts){
System.out.println(context);
//只打印出 NATIVE_APP
}
如题,使用 getContextHandles() 方法只返回 NATIVE_APP,这个应用就一定是原生应用吗?源码如上
但是我使用 UI Automator viewer 却看到了 WEBVIEW 标签。。如下图