无法在 appium 项目中启动具有正确功能的 android 驱动程序
Unable to initiate android driver with the right capabilities in appium project
我是移动自动化的新手,正在尝试使用 Eclipse 设置 appium,并且还成功连接了真实设备。我已经安装了所有必需的软件和软件包。我可以在 adb 设备列表下找到我的设备。
我在eclipse 中创建了一个简单的项目,并在DesiredCapabilities 方法中声明了所有正确的参数。我还包含了 appPackage 和 appActivity,但我的错误显示
The desired capabilities must include either 'appPackage' or 'browserName'
public class NewTest {
AndroidDriver driver;
AppiumDriverLocalService service;
@Test
public void f() {
driver.findElement(By.id("com.google.android.youtube:id/menu_search")).click();
driver.findElement(By.xpath("com.google.android.youtube:id/search_edit_text")).sendKeys("nota");
}
@BeforeTest
public void beforeTest() {
service = AppiumDriverLocalService.buildDefaultService();
service.start();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "S51C1LV1C0056422");
capabilities.setCapability("browserName", "Android");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.google.android.youtube");
capabilities.setCapability("appActivity", "com.google.android.apps.youtube.app.WatchWhileActivity");
try {
driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
@AfterTest
public void afterTest() {
service = AppiumDriverLocalService.buildDefaultService();
service.stop();
driver.quit();
}
}
下面是控制台输出。
[RemoteTestNG] detected TestNG version 6.14.2
[35m[Appium][39m Welcome to Appium v1.9.0
[35m[Appium][39m Appium REST http interface listener started on 0.0.0.0:4723
[35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/status[39m
[35m[HTTP][39m [90m{}[39m
[debug] [35m[MJSONWP][39m Calling AppiumDriver.getStatus() with args: []
[debug] [35m[MJSONWP][39m Responding to client with driver.getStatus() result: {"build":{"version":"1.9.0"}}
[35m[HTTP][39m [37m<-- GET /wd/hub/status [39m[32m200[39m [90m17 ms - 67[39m
[35m[HTTP][39m [90m[39m
[35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m
[35m[HTTP][39m [90m{"desiredCapabilities":{"appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appPackage":"com.google.android.youtube","platformVersion":"4.4.2","browserName":"Android","platformName":"Android","deviceName":"S51C1LV1C0056422"},"capabilities":{"alwaysMatch":{"appium:appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appium:appPackage":"com.google.android.youtube","browserName":"Android","appium:deviceName":"S51C1LV1C0056422","platformName":"android","appium:platformVersion":"4.4.2"},"firstMatch":[{}]}}[39m
[debug] [35m[MJSONWP][39m Calling AppiumDriver.createSession() with args: [{"appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appPackage":"com.google.android.youtube","platformVersion":"4.4.2","browserName":"Android","platformName":"Android","deviceName":"S51C1LV1C0056422"},null,{"alwaysMatch":{"appium:appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appium:appPackage":"com.google.android.youtube","browserName":"Android","appium:deviceName":"S51C1LV1C0056422","platformName":"android","appium:platformVersion":"4.4.2"},"firstMatch":[{}]}]
[debug] [35m[BaseDriver][39m Event 'newSessionRequested' logged at 1536289004500 (08:26:44 GMT+0530 (India Standard Time))
[35m[Appium][39m Creating new AndroidDriver (v3.7.0) session
[35m[Appium][39m Capabilities:
[35m[Appium][39m browserName: Android
[35m[Appium][39m platformName: android
[35m[Appium][39m appActivity: com.google.android.apps.youtube.app.WatchWhileActivity
[35m[Appium][39m appPackage: com.google.android.youtube
[35m[Appium][39m deviceName: S51C1LV1C0056422
[35m[Appium][39m platformVersion: 4.4.2
[debug] [35m[BaseDriver][39m W3C capabilities {"alwaysMatch":{"browserNam... and MJSONWP desired capabilities {"appActivity":"com.google.... were provided
[debug] [35m[BaseDriver][39m Creating session with W3C capabilities: {"alwaysMatch":{"browserNam...
[35m[AndroidDriver][39m Error: The desired capabilities must include either 'appPackage' or 'browserName'
[35m[AndroidDriver][39m at Object.wrappedLogger.errorAndThrow (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-support\lib\logging.js:78:13)
[35m[AndroidDriver][39m at Object.helpers.validateDesiredCaps (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:705:14)
[35m[AndroidDriver][39m at AndroidDriver.validateDesiredCaps (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\driver.js:470:20)
[35m[AndroidDriver][39m at AndroidDriver.callee[=12=][=12=]$ (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\session.js:45:8)
[35m[AndroidDriver][39m at tryCatch (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at invoke (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[35m[AndroidDriver][39m at enqueueResult (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
[35m[AndroidDriver][39m at new Promise (<anonymous>)
[35m[AndroidDriver][39m at new F (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules$.export.js:30:36)
[35m[AndroidDriver][39m at AsyncIterator.enqueue (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
[35m[AndroidDriver][39m at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at Object.runtime.async (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
[35m[AndroidDriver][39m at AndroidDriver.callee[=12=][=12=] [as createSession] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\build\lib\basedriver\commands\session.js:35:30)
[35m[AndroidDriver][39m at AndroidDriver.createSession$ (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\driver.js:29:20)
[35m[AndroidDriver][39m at tryCatch (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at invoke (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[35m[AndroidDriver][39m at enqueueResult (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
[35m[AndroidDriver][39m at new Promise (<anonymous>)
[35m[AndroidDriver][39m at new F (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules$.export.js:30:36)
[35m[AndroidDriver][39m at AsyncIterator.enqueue (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
[35m[AndroidDriver][39m at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at Object.runtime.async (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
[35m[AndroidDriver][39m at AndroidDriver.createSession (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\build\lib\driver.js:140:34)
[35m[AndroidDriver][39m at AppiumDriver.callee[=12=]$ (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\lib\appium.js:293:43)
[35m[AndroidDriver][39m at tryCatch (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[35m[AndroidDriver][39m at <anonymous>
[35m[AndroidDriver][39m at process._tickCallback
如果你传递 browserName
和 appPackage
两个 capabilities
那么这意味着它是矛盾的,因为 appium 将无法理解它必须启动
浏览器(基于 browerName
上限)或应用程序(基于 appPackage
上限)
Remove browser name capability
capabilities.setCapability("browserName", "Android");
Add this capability
capabilities.setCapability("platformName", "Android");
您必须定义 AppiumDriver 而不是 AndroidDriver。
public class NewTest {
AppiumDriver<WebElement> driver;
//...
}
包括 appPackage、appActivity、platformName、deviceName 在所需功能中。
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Android phone");
caps.setCapability("platformName", "Android");
caps.setCapability("appPackage", "Your app Package");
caps.setCapability("appActivity", "app activity name");
Don't include browserName if you are not opening your app in web browser.
像下面这样初始化你的驱动程序:
driver = new AndroidDriver<WebElement>(new URL(
"http://0.0.0.0:4723/wd/hub"), caps);
我是移动自动化的新手,正在尝试使用 Eclipse 设置 appium,并且还成功连接了真实设备。我已经安装了所有必需的软件和软件包。我可以在 adb 设备列表下找到我的设备。
我在eclipse 中创建了一个简单的项目,并在DesiredCapabilities 方法中声明了所有正确的参数。我还包含了 appPackage 和 appActivity,但我的错误显示
The desired capabilities must include either 'appPackage' or 'browserName'
public class NewTest {
AndroidDriver driver;
AppiumDriverLocalService service;
@Test
public void f() {
driver.findElement(By.id("com.google.android.youtube:id/menu_search")).click();
driver.findElement(By.xpath("com.google.android.youtube:id/search_edit_text")).sendKeys("nota");
}
@BeforeTest
public void beforeTest() {
service = AppiumDriverLocalService.buildDefaultService();
service.start();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "S51C1LV1C0056422");
capabilities.setCapability("browserName", "Android");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.google.android.youtube");
capabilities.setCapability("appActivity", "com.google.android.apps.youtube.app.WatchWhileActivity");
try {
driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
@AfterTest
public void afterTest() {
service = AppiumDriverLocalService.buildDefaultService();
service.stop();
driver.quit();
}
}
下面是控制台输出。
[RemoteTestNG] detected TestNG version 6.14.2
[35m[Appium][39m Welcome to Appium v1.9.0
[35m[Appium][39m Appium REST http interface listener started on 0.0.0.0:4723
[35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/status[39m
[35m[HTTP][39m [90m{}[39m
[debug] [35m[MJSONWP][39m Calling AppiumDriver.getStatus() with args: []
[debug] [35m[MJSONWP][39m Responding to client with driver.getStatus() result: {"build":{"version":"1.9.0"}}
[35m[HTTP][39m [37m<-- GET /wd/hub/status [39m[32m200[39m [90m17 ms - 67[39m
[35m[HTTP][39m [90m[39m
[35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m
[35m[HTTP][39m [90m{"desiredCapabilities":{"appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appPackage":"com.google.android.youtube","platformVersion":"4.4.2","browserName":"Android","platformName":"Android","deviceName":"S51C1LV1C0056422"},"capabilities":{"alwaysMatch":{"appium:appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appium:appPackage":"com.google.android.youtube","browserName":"Android","appium:deviceName":"S51C1LV1C0056422","platformName":"android","appium:platformVersion":"4.4.2"},"firstMatch":[{}]}}[39m
[debug] [35m[MJSONWP][39m Calling AppiumDriver.createSession() with args: [{"appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appPackage":"com.google.android.youtube","platformVersion":"4.4.2","browserName":"Android","platformName":"Android","deviceName":"S51C1LV1C0056422"},null,{"alwaysMatch":{"appium:appActivity":"com.google.android.apps.youtube.app.WatchWhileActivity","appium:appPackage":"com.google.android.youtube","browserName":"Android","appium:deviceName":"S51C1LV1C0056422","platformName":"android","appium:platformVersion":"4.4.2"},"firstMatch":[{}]}]
[debug] [35m[BaseDriver][39m Event 'newSessionRequested' logged at 1536289004500 (08:26:44 GMT+0530 (India Standard Time))
[35m[Appium][39m Creating new AndroidDriver (v3.7.0) session
[35m[Appium][39m Capabilities:
[35m[Appium][39m browserName: Android
[35m[Appium][39m platformName: android
[35m[Appium][39m appActivity: com.google.android.apps.youtube.app.WatchWhileActivity
[35m[Appium][39m appPackage: com.google.android.youtube
[35m[Appium][39m deviceName: S51C1LV1C0056422
[35m[Appium][39m platformVersion: 4.4.2
[debug] [35m[BaseDriver][39m W3C capabilities {"alwaysMatch":{"browserNam... and MJSONWP desired capabilities {"appActivity":"com.google.... were provided
[debug] [35m[BaseDriver][39m Creating session with W3C capabilities: {"alwaysMatch":{"browserNam...
[35m[AndroidDriver][39m Error: The desired capabilities must include either 'appPackage' or 'browserName'
[35m[AndroidDriver][39m at Object.wrappedLogger.errorAndThrow (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-support\lib\logging.js:78:13)
[35m[AndroidDriver][39m at Object.helpers.validateDesiredCaps (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:705:14)
[35m[AndroidDriver][39m at AndroidDriver.validateDesiredCaps (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\driver.js:470:20)
[35m[AndroidDriver][39m at AndroidDriver.callee[=12=][=12=]$ (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\session.js:45:8)
[35m[AndroidDriver][39m at tryCatch (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at invoke (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[35m[AndroidDriver][39m at enqueueResult (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
[35m[AndroidDriver][39m at new Promise (<anonymous>)
[35m[AndroidDriver][39m at new F (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules$.export.js:30:36)
[35m[AndroidDriver][39m at AsyncIterator.enqueue (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
[35m[AndroidDriver][39m at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at Object.runtime.async (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
[35m[AndroidDriver][39m at AndroidDriver.callee[=12=][=12=] [as createSession] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\build\lib\basedriver\commands\session.js:35:30)
[35m[AndroidDriver][39m at AndroidDriver.createSession$ (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\driver.js:29:20)
[35m[AndroidDriver][39m at tryCatch (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at invoke (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[35m[AndroidDriver][39m at enqueueResult (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
[35m[AndroidDriver][39m at new Promise (<anonymous>)
[35m[AndroidDriver][39m at new F (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules$.export.js:30:36)
[35m[AndroidDriver][39m at AsyncIterator.enqueue (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
[35m[AndroidDriver][39m at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at Object.runtime.async (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
[35m[AndroidDriver][39m at AndroidDriver.createSession (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\build\lib\driver.js:140:34)
[35m[AndroidDriver][39m at AppiumDriver.callee[=12=]$ (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\lib\appium.js:293:43)
[35m[AndroidDriver][39m at tryCatch (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[35m[AndroidDriver][39m at GeneratorFunctionPrototype.invoke (C:\Users\WELCOME\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[35m[AndroidDriver][39m at <anonymous>
[35m[AndroidDriver][39m at process._tickCallback
如果你传递 browserName
和 appPackage
两个 capabilities
那么这意味着它是矛盾的,因为 appium 将无法理解它必须启动
浏览器(基于 browerName
上限)或应用程序(基于 appPackage
上限)
Remove browser name capability
capabilities.setCapability("browserName", "Android");
Add this capability
capabilities.setCapability("platformName", "Android");
您必须定义 AppiumDriver 而不是 AndroidDriver。
public class NewTest {
AppiumDriver<WebElement> driver;
//...
}
包括 appPackage、appActivity、platformName、deviceName 在所需功能中。
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Android phone");
caps.setCapability("platformName", "Android");
caps.setCapability("appPackage", "Your app Package");
caps.setCapability("appActivity", "app activity name");
Don't include browserName if you are not opening your app in web browser.
像下面这样初始化你的驱动程序:
driver = new AndroidDriver<WebElement>(new URL(
"http://0.0.0.0:4723/wd/hub"), caps);