2020import static testUI .Utils .Logger .putLogInfo ;
2121
2222public class IOSTestUIDriver {
23- protected static void startFirstIOSDriver (DesiredCapabilities desiredCapabilities ) {
23+ protected static void startFirstIOSDriver () {
2424 String url = Configuration .appiumUrl .isEmpty () ?
2525 "http://127.0.0.1:" + getUsePort ().get (0 ) + "/wd/hub" : Configuration .appiumUrl ;
26- for (int i = 0 ; i < 2 ; i ++) {
26+ for (int i = 0 ; true ; i ++) {
27+ DesiredCapabilities cap = setIOSCapabilities (false );
2728 try {
2829 putLog ("Starting appium driver..." );
2930 if (getDrivers ().size () == 0 ) {
3031 TestUIDriver .setDriver (new IOSDriver (
31- new URL (url ), desiredCapabilities ) {});
32+ new URL (url ), cap ) {});
3233 } else {
3334 TestUIDriver .setDriver (new IOSDriver (
34- new URL (url ), desiredCapabilities ) {}, 0 );
35+ new URL (url ), cap ) {}, 0 );
3536 }
37+ Configuration .driver = 1 ;
3638 attachShutDownHookStopDriver (getDriver ());
37- break ;
39+ return ;
3840 } catch (Exception e ) {
3941 putLogError ("Could not create driver! retrying..." );
4042 sleep (500 );
@@ -51,7 +53,7 @@ protected static void startFirstIOSDriver(DesiredCapabilities desiredCapabilitie
5153 protected static void startFirstIOSBrowserDriver (String urlOrRelativeUrl ) {
5254 String url = Configuration .appiumUrl .isEmpty () ?
5355 "http://127.0.0.1:" + getUsePort ().get (0 ) + "/wd/hub" : Configuration .appiumUrl ;
54- for (int i = 0 ; i < 2 ; i ++) {
56+ for (int i = 0 ; true ; i ++) {
5557 DesiredCapabilities cap = setIOSCapabilities (true );
5658 try {
5759 putLog ("Starting appium driver..." );
@@ -63,13 +65,13 @@ protected static void startFirstIOSBrowserDriver(String urlOrRelativeUrl) {
6365 Configuration .driver = 1 ;
6466 getDriver ().get (urlOrRelativeUrl );
6567 attachShutDownHookStopDriver (getDriver ());
66- break ;
68+ return ;
6769 } catch (MalformedURLException e ) {
6870 e .printStackTrace ();
6971 } catch (Exception e ) {
7072 putLogError ("Could not create driver! retrying..." );
7173 sleep (500 );
72- if (i == 1 ) {
74+ if (i == 0 ) {
7375 e .printStackTrace ();
7476 throw new Error (e );
7577 }
0 commit comments