gpt4 book ai didi

java - 如何正确地将应用程序文件添加到appium Desired Capabilities?

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

我使用了 SauceLabs example

   DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("BROWSER_NAME", "Android");
capabilities.setCapability("VERSION", "4.4.2");
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("platformName", "Android");

//zip file containing your app to be tested
capabilities.setCapability("app", "http://appium.s3.amazonaws.com/TestApp6.0.app.zip");

driver = new RemoteWebDriver
(new URL(MessageFormat.format("http://{0}:{1}@ondemand.saucelabs.com:80/wd/hub",
sauceUserName, sauceAccessKey)), capabilities);

这是完美的工作。但是当我用app下载zip并切换到本地环境时

capabilities.setCapability("app", app.getAbsolutePath());    
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);

我从 appium 控制台收到错误:

error: Failed to start an Appium session, err was: Error: Bad app: /home/.../appium/assets/TestApp6.0.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: App zip unzipped OK, but we couldn't find a .app bundle in it. Make sure your archive contains the .app package and nothing else

最佳答案

试试这个而不是 RemoteWebDriver:使用 AndroidDriver。此外,如果您从 localhost 运行,请提及 IP 地址或仅键入 "localhost"

capabilities.setCapability("app", app.getAbsolutePath());    
driver = new AndroidDriver (new URL("http://localhost:4723/wd/hub"), capabilities);

创建一个名为 “app” 的文件夹,并将您的测试 Android 应用程序放在那里。

示例代码:

File filePath = new File(System.getProperty("user.dir"));
File appDir = new File(filePath, "/app");
File app = new File(appDir, "yourapkfile.apk");

关于java - 如何正确地将应用程序文件添加到appium Desired Capabilities?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30532771/

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