我有以下方案自动化。如何通过Appium实现这一目标。
1. Launch my application register a user with an gmail id.
2. Close the application.
3. Launch Safari browser and navigate to gmail login
4. Click on the registration link.
这里,具有挑战性的部分是第2点和第3点。 Appium会话可以断开吗? Appium可以为Safari等预先安装的应用程序启动新会话吗?
答案 0 :(得分:3)
您可以使用相同的appium服务器实例。无需终止服务器,但您可能希望使用两个不同的驱动程序实例。
AppiumDriverLocalService service;
IOSDriver iosDriver;
public void setUp() throws IOException {
service = AppiumDriverLocalService.buildDefaultService();
service.start();
}
public void startMyApplication(){
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone");
dc.setCapability(MobileCapabilityType.UDID, "3838n838fn38jf8n838ffabcdefg");
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
dc.setCapability(MobileCapabilityType.APP, "com.your_package.name");
iosDriver = new IOSDriver("http://localhost:4723/wd/hub", dc);
}
public void testMyGoogleLoginOnMyApplication(){
//I intend to do something here
//Once i am finished, I close my application
iosDriver.quit();
}
public void startSafari(){
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone");
dc.setCapability(MobileCapabilityType.UDID, "3838n838fn38jf8n838ffabcdefg");
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
dc.setCapability(MobileCapabilityType.APP, "com.safari_package.name");
iosDriver = new IOSDriver("http://localhost:4723/wd/hub", dc);
}
public void testSafari(){
//I intend to go to google and do stuff
//Once i am finished, I close my application
iosDriver.quit();
}
public void finished(){
service.stop();
}
答案 1 :(得分:0)
刚刚遇到适用于所有iOS版本和Xcode版本的解决方案:
driver.background_app(-1) 从跳板中找到Icon并单击它!