gpt4 book ai didi

java - 使用 Appium 进行 Android 测试用例

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

有谁知道如何使用 Eclipse 在 Windows 上运行 Appium Testcase。

我的问题是。如何为我的 Android 设备上已安装的 .apk 运行测试用例。

因为我正在使用的示例,每次测试用例运行时它都会安装 apk。

@Before
public void setUp() throws Exception {

File appDir = new File("src/Test");
File app = new File(appDir, "MyTest.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ""); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
capabilities.setCapability(MobileCapabilityType.VERSION, "4.4");
capabilities.setCapability(MobileCapabilityType.PLATFORM, "Android");
capabilities.setCapability("app-package", "com.TuneBox.Rokki");
capabilities.setCapability("app-activity", ".MyTest");

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

}

最佳答案

确保您的应用已安装在设备上 - 否则您将收到

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity) (WARNING: The server did not provide any stacktrace information) 

然后只需从代码中删除 MobileCapabilityType.APP 功能即可。 Appium 将启动之前安装的应用程序。

关于java - 使用 Appium 进行 Android 测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30499420/

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