这是工作代码。但是一旦被AndroidDriver取代,它就会在运行程序时开始抛出错误。已成功导入了库,甚至可以获得AndroidDriver方法,但运行时出错。
public class TestClass {
WebDriver d=null;
@BeforeMethod
public void Start() throws MalformedURLException
{
// ConstVariables.DesiredSetting();
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability("BROWSER_NAME","Android");
capabilities.setCapability("VERSION","6.0.1");
capabilities.setCapability("deviceName","ZY223JX5QN");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.aaa.bapp");
capabilities.setCapability("appActivity","com.aaa.bapp.activity.SplashActivity");
d= new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
d.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
}
答案 0 :(得分:0)
您可以查看以下代码是否适合您吗?我刚刚改变了初始化WebDriver的方式。休息所有代码应该是相同的。
AppiumDriver<WebElement> d;
..... your code .....
d = new AndroidDriver<WebElement>("http://127.0.0.1:4723/wd/hub"), capabilities);