我的移动模拟器测试设置有问题。
基本上我有一个移动设备列表,可以用来在移动设备上运行我的硒测试。这些是一个设备池,任何支付服务费用的人都可以使用,因此有时这些设备可能会被使用,这将创建一个会话未创建的异常。我遇到的问题是我正在使用尝试/捕获以确保如果一个设备不可用,则可以使用另一组设备功能。我遇到的问题是,有时两个设备都在使用并且测试被忽略。这是我当前的代码:
@BeforeClass
public void setup()throws Exception{
//Setup a mobile device on Kobiton, if this one is not available, the next one will be used
try {
this.driver = new RemoteWebDriver(config.kobitonServerUrl(), config.desiredCapabilitites_galaxyss7());
} catch (SessionNotCreatedException e) {
System.out.println("Secondary device being used");
this.driver = new RemoteWebDriver(config.kobitonServerUrl(), config.desiredCapabilitites_galaxys7());
}
}
我已经使用以下代码绑定,但不允许 (!done)
boolean done = false;
while (!done) {
try {
...
done = true;
} catch (...) {
}
}
我尝试过这样的循环,但没有任何反应
@BeforeClass
public void setup()throws Exception{
boolean done = false;
while (!done)
try {
this.driver = new RemoteWebDriver (config.kobitonServerUrl(),
config.desiredCapabilitites_galaxyss7());
done = true;
} catch (SessionNotCreatedException e){
System.out.println("Secondary device being used");
this.driver = new RemoteWebDriver (config.kobitonServerUrl(),
config.desiredCapabilitites_galaxys7());
done = true;
}
}
我也尝试过
public class how_to_play_test {
private RemoteWebDriver driver = null;
@BeforeClass
public void setup()throws Exception{
int max_attempts = 10;
int attempts = 0;
boolean done = false;
while (attempts<max_attempts && !done) {
try {
this.driver = new RemoteWebDriver(config.kobitonServerUrl(), config.desiredCapabilitites_galaxyss7());
done = true;
} catch (SessionNotCreatedException e) {
System.out.println("Secondary device being used");
this.driver = new RemoteWebDriver(config.kobitonServerUrl(), config.desiredCapabilitites_galaxys7());
done = true;
}
attempts ++;
}
}
德玛西亚99
相关分类