gpt4 book ai didi

java - Appium - 无法实例化 AndroidDriver

转载 作者:行者123 更新时间:2023-11-30 08:07:02 26 4
gpt4 key购买 nike

当我尝试实例化 AndroidDriver 类时出现错误。请帮忙。

代码

import io.appium.java_client.android.AndroidDriver;

public class Testing {
@Test
public void testMethod() {
AndroidDriver driver;
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "samsung-sm_g530h-5554c610");
cap.setCapability("platformVersion", "4.4.4");
cap.setCapability("platformName", "Android");
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("appPackage", "com.whatsapp");
cap.setCapability("appActivity", "com.whatsapp.HomeActivity");
driver = new AndroidDriver(new URL("127.0.0.1:4723"), cap);
}
}

//这里是错误 enter image description here

最佳答案

报错:AndroidDriver 是 Raw 类型。您可以按如下方式初始化驱动程序:

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
...
public class Testing()
{
public AppiumDriver driver;
...
@BeforeTest
public void testMethod()
{
driver = new AndroidDriver(new URL(Node), capabilities);
...
}
}

关于java - Appium - 无法实例化 AndroidDriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33944450/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com