尝试在多台设备上并行执行我的appium测试。
我目前可以在一台Android设备上执行我的测试用例。在切换和改变后,我无法让我的测试并行运行。
继续我目前的设置。希望在不需要酱油或硒网格的情况下并行执行测试。
我的Junit跑步者的例子
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"json:target/cucumber.json", "pretty"}, features = {
"src/test/resources/features/
},
glue = "com.test.stepdefs")
public class RunCukesTest {
private static AppiumDriverLocalService service;
public static File file;
@BeforeClass
public static void startAppium() throws IOException {
System.out.println("YOUR OS NAME : " + osName);
String nodePath = null;
String appiumPath = null;
ServerArgument argument;
if (osName.contains("mac")) {
// mac paths
nodePath = "/usr/local/bin/node";
appiumPath = "/usr/local/lib/node_modules/appium/build/lib/main.js";
service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(nodePath))
.usingPort(4723)
.withArgument(GeneralServerFlag.LOG_LEVEL,
"error")
.withAppiumJS(new File(appiumPath)));
} else if (osName.contains("windows")) {
service = AppiumDriverLocalService.buildDefaultService();
} else if (osName.contains("linux")) {
// linuxs path
nodePath = System.getenv("PRODUCTION") + "/.linuxbrew/bin/node";
appiumPath =
System.getenv("PRODUCTION") + "/.linuxbrew/lib/node_modules/appium/build/lib/main.js";
service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(nodePath))
.usingPort(4723)
.withAppiumJS(new File(appiumPath)));
}
service.addOutPutStream(stream);
service.start();
}
@AfterClass
public static void stopAppium() {
service.stop();
}
和我的一个例子
@Configuration
public class AppUtils {
@Value("${explicit.wait}")
public int explicitWaitTime;
@Value("${implicit.wait}")
public int implicitWaitTime;
@Value("${default.wait}")
public int defaultWaitTime;
public String applicationName;
public DesiredCapabilities capabilities;
@Value("${appium.server.port}")
private String appiumPort;
@Value("${automation.instrumentation}")
private String instrumentation;
@Value("${browser.name}")
private String browserName;
@Value("${platform.name}")
private String platformName;
@Value("${device.name}")
private String deviceName;
@Value("${platform.version}")
private String platformVersion;
@Value("${new.command.timeout}")
private String newCommandTimeout;
@Value("${app.package}")
private String appPackage;
@Value("${device.ready.timeout}")
private String deviceReadyTimeout;
private URL serverUrl;
private AppiumDriver<? extends MobileElement> driver;
@Bean(destroyMethod = "quit")
@Scope("cucumber-glue")
public AndroidDriver getDriver() throws MalformedURLException {
capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, platformVersion);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, platformName);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, instrumentation);
capabilities.setCapability("appPackage", "com.android.chrome"); //To be moved to properties
capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main"); //To be moved to properties
serverUrl = new URL("http://localhost:" + appiumPort + "/wd/hub");
// LoggingPreferences logPrefs = new LoggingPreferences();
// logPrefs.addPreferences()
// capabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);
driver = new AndroidDriver(serverUrl, capabilities);
driver.manage().timeouts().implicitlyWait(implicitWaitTime, TimeUnit.SECONDS);
//driver.setLogLevel(Level.OFF);
return (AndroidDriver) driver;
}
}
找不到任何关于此的好文档,并感谢任何帮助。
答案 0 :(得分:0)
您应该启动另一个在不同端口上侦听的appium服务器实例,然后使用这个新的服务器端口功能启动测试。