这是我正在创建的BeforeClass(Java,Appium,TestNG)
AndroidDriver专用驱动程序;
@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, "1.7.1");
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
desiredCapabilities.setCapability("deviceName", "9NLJA17619012618");
desiredCapabilities.setCapability("appActivity", ".activity.LaunchActivity");
desiredCapabilities.setCapability("appPackage", "com.aaa.app");
desiredCapabilities.setCapability("platformVersion", "7.1.2");
URL url = new URL("http://localhost:4723/wd/hub");
driver = new AndroidDriver(url,desiredCapabilities);
}
(我知道MobileCapabilityType和其他没有该格式的混合,但这不是我想的重点)
然后是一堆@Test
出现此错误:
Failed tests: setUp(tests.TestShop):
class io.appium.java_client.android.AndroidDriver has interface io.appium.java_client.AppiumDriver as super class
任何线索?
答案 0 :(得分:2)
添加 MobileElement 或 WebElement 。
driver = new AndroidDriver<MobileElement>(url,desiredCapabilities);
还要将您的 deviceName 更改为已拒绝。另外,请确保您的 appActivity 是正确的。
您的代码必须如下所示:
@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("platformName","Android");
desiredCapabilities.setCapability("deviceName", "Any name");
desiredCapabilities.setCapability("udid", "9NLJA17619012618");
desiredCapabilities.setCapability("appActivity", ".activity.LaunchActivity");
desiredCapabilities.setCapability("appPackage", "com.aaa.app");
desiredCapabilities.setCapability("platformVersion", "7.1.2");
URL url = new URL("http://localhost:4723/wd/hub");
driver = new AndroidDriver<MobileElement>(url,desiredCapabilities);
}