gpt4 book ai didi

java - 无法通过appium在android模拟器中启动计算器

转载 作者:太空宇宙 更新时间:2023-11-04 13:11:59 25 4
gpt4 key购买 nike

我只是创建了一个示例代码,如下所示,用于启动计算器 apk 文件并执行一些任务

@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 中都会返回以下异常。有人可以告诉我如何克服这个问题。 session 似乎正在进行,但我不确定如何终止较早开始的进度 session 。我尝试以 appium --no-reset 方式启动 appium 服务器,并检查覆盖现有 session ,但没有成功。

 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

请帮帮我。

最佳答案

您收到的错误[INSTALL_FAILED_OLDER_SDK]是由于您的avd/设备的android版本比用于编译应用程序代码的版本旧而引起的。检查目标sdk版本和应用程序的最低sdk版本。

如果您有权访问应用程序的源代码,这些信息将位于 android:minSdkVersion 标记的 list 文件中。

关于java - 无法通过appium在android模拟器中启动计算器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33869047/

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