1
在Android模擬器啓動計算器我剛剛創建的示例代碼如下這是用來啓動計算器apk文件,並執行一些任務未能通過appium
@BeforeSuite
public static void driverInitalize() throws Exception {
try {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.2.2");
// capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
capabilities
.setCapability("app",
"C:\\Ecare\\Appium\\com.android.calculator2-5.1-1720659-22-minAPI22.apk");
driver = new RemoteWebDriver(
new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Test
public static void sampleTest1() throws Exception {
try {
// System.out.println(driver.getTitle());
driver.findElement(By.xpath(".//*[contains(text(),'7')]")).click();
driver.findElement(By.xpath(".//*[contains(text(),'+')]")).click();
driver.findElement(By.xpath(".//*[contains(text(),'3')]")).click();
driver.findElement(By.xpath(".//*[contains(text(),'=')]")).click();
String value = driver.findElement(
By.className("android.widget.EditText")).getText();
System.out.print(value);
} catch (Exception ex) {
ex.printStackTrace();
}
}
@AfterSuite
public static void tearDown() throws Exception {
try {
driver.quit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
每當我執行上面的代碼將返回以下異常在appium服務器以及eclipse IDE中。有人可以告訴我如何解決這個問題。這似乎是會議進展,但我不知道如何殺死更早開始的進度會話。我嘗試將appium服務器啓動爲appium --no-reset,並在覆蓋現有會話中進行檢查,但沒有運氣。
Failure [INSTALL_FAILED_OLDER_SDK]
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1358:17
> at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
> at ChildProcess.exithandler (child_process.js:635:7)
> at ChildProcess.EventEmitter.emit (events.js:98:17)
> at maybeClose (child_process.js:743:16)
> at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Remote install failed: pkg: /data/local/tmp/b23beec2f0794d869eb021f75e3791bd.apk\r\r\nFailure [INSTALL_FAILED_OLDER_SDK])","origValue":"Remote install failed: pkg: /data/local/tmp/b23beec2f0794d869eb021f75e3791bd.apk\r\r\nFailure [INSTALL_FAILED_OLDER_SDK]"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 39088.716 ms - 362
請幫幫我。
謝謝它的修復。 – SKumar