mardi 17 septembre 2019

Restart Test in selenium if a certain exception occurs

I am running my selenium mobile tests through kobiton and an issue i keep finding is that as im using a public phones, they may be in use when i try to run the tests Im getting the following message

org.openqa.selenium.SessionNotCreatedException: No device matching the desired capabilities

My current code setup is

@BeforeClass
public void setup()throws Exception{

    String kobitonServerUrl = "https://f:a15e3b93-a1dd3c-4736-bdfb- 
006221ezz8c2a2cz@api.kobiton.com/wd/hub";

    this.driver = new RemoteWebDriver (config.kobitonServerUrl(), 
config.desireCapabilitites_iphone8());

}

Id like to be able to be able to try

    this.driver = new RemoteWebDriver (config.kobitonServerUrl(), config.desireCapabilitites_iphone9() )

if the iphone 8 is unavailable, so i thought a if and else could work but i dont know how to do this for a specific exception?

Aucun commentaire:

Enregistrer un commentaire