13
13
import org .openqa .selenium .remote .RemoteWebDriver ;
14
14
import org .openqa .selenium .remote .SessionNotFoundException ;
15
15
16
-
17
- public class Env
16
+ public class Env
18
17
{
19
18
public static RemoteWebDriver driver = null ;
20
19
static String browserName = null ;
21
20
static Boolean isMobile ;
22
-
21
+
23
22
public static String getBrowserName ()
24
23
{
25
- browserName = System .getProperty ("browser" );
26
-
24
+ browserName = System .getProperty ("browser" );
25
+
27
26
if (browserName == null )
28
27
browserName = "ff" ;
29
28
return browserName ;
30
29
}
31
-
30
+
32
31
public static RemoteWebDriver CreateWebDriver (String browser )
33
32
{
34
33
DesiredCapabilities capabilities = new DesiredCapabilities ();
35
34
System .out .println ("Browser: " + browser );
36
-
35
+
37
36
switch (browser .toLowerCase ()) {
38
37
case "mobileandroid" :
39
38
capabilities .setCapability ("platformName" ,"Android" );
@@ -52,7 +51,7 @@ public static RemoteWebDriver CreateWebDriver(String browser)
52
51
capabilities .setCapability ("browserName" , "Firefox" );
53
52
capabilities .setCapability ("browserVersion" , "45" );
54
53
capabilities .setCapability ("resolution" , "1440x900" );
55
- capabilities .setCapability ("location" , "US East" );
54
+ capabilities .setCapability ("location" , "US East" );
56
55
isMobile = false ;
57
56
break ;
58
57
@@ -79,45 +78,98 @@ public static RemoteWebDriver CreateWebDriver(String browser)
79
78
break ;
80
79
81
80
case "safari" :
82
- System .out .println ("Safari not supported yet" );
81
+ System .out .println ("Safari not supported yet" );
83
82
break ;
84
-
83
+
85
84
default :
86
85
System .out .println ("Invalid browser name " +browser );
87
86
System .exit (0 );
88
- break ;
87
+ break ;
89
88
}//switch
90
-
91
-
89
+
90
+
92
91
if (isMobile )
93
92
{
94
93
capabilities .setCapability ("browserName" , "mobileOS" );
95
94
capabilities .setCapability ("automationName" , "PerfectoMobile" );
96
95
}
97
-
96
+
98
97
capabilities .setCapability ("user" , System .getProperty ("PerfectoUser" ));
99
- capabilities .setCapability ("password" , System .getProperty ("PerfectoPassword" ));
100
- capabilities .setCapability ("newCommandTimeout" , "120" );
98
+ capabilities .setCapability ("password" , System .getProperty ("PerfectoPassword" ));
99
+ capabilities .setCapability ("newCommandTimeout" , "120" );
101
100
capabilities .setCapability ("scriptName" , "Selenium Responsive" );
102
-
101
+
103
102
try {
104
103
driver = new RemoteWebDriver (new URL (System .getProperty ("PerfectoCloud" ) + "/nexperience/perfectomobile/wd/hub" ), capabilities );
105
104
} catch (MalformedURLException e ) {
106
105
// TODO Auto-generated catch block
107
106
e .printStackTrace ();
108
107
}
109
-
108
+
110
109
if (isMobile )
111
110
{
112
111
RemoteExecuteMethod executeMethod = new RemoteExecuteMethod (driver );
113
112
Map <String ,String > params = new HashMap <String ,String >();
114
113
params .put ("name" , "WEBVIEW" );
115
114
executeMethod .execute (DriverCommand .SWITCH_TO_CONTEXT , params );
116
115
}
117
-
116
+
118
117
driver .manage ().timeouts ().implicitlyWait (60 , TimeUnit .SECONDS );
119
-
120
-
118
+
119
+
121
120
return driver ;
122
121
}
123
- }
122
+
123
+ // public class Env {
124
+ // static WebDriver driver = null;
125
+ // static String browserName = null;
126
+ //
127
+ // public static String getBrowserName() {
128
+ // browserName = System.getProperty("browser");
129
+ //
130
+ // if (browserName == null)
131
+ // browserName = "ff";
132
+ // return browserName;
133
+ // }
134
+ //
135
+ // public static WebDriver CreateWebDriver(String browser) {
136
+ // System.out.println("Browser: " + browser);
137
+ //
138
+ // switch (browser.toLowerCase()) {
139
+ // case "ff":
140
+ // case "firefox":
141
+ // // ProfilesIni allProfiles = new ProfilesIni();
142
+ // // FirefoxProfile profile = allProfiles.getProfile("selenium");
143
+ // // driver = new FirefoxDriver(profile);
144
+ // driver = new FirefoxDriver();
145
+ // break;
146
+ //
147
+ // case "ch":
148
+ // case "chrome":
149
+ // driver = new ChromeDriver();
150
+ // break;
151
+ //
152
+ // case "ie":
153
+ // case "internetexplorer":
154
+ // driver = new InternetExplorerDriver();
155
+ // break;
156
+ //
157
+ // case "safari":
158
+ // driver = new SafariDriver();
159
+ // break;
160
+ //
161
+ // default:
162
+ // System.out.println("Invalid browser name " + browser);
163
+ // System.exit(0);
164
+ // break;
165
+ // }// switch
166
+ //
167
+ // driver.manage().deleteAllCookies();
168
+ // driver.manage().window().maximize();
169
+ // driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
170
+ // driver.manage().timeouts().setScriptTimeout(60, TimeUnit.SECONDS);
171
+ // driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
172
+ //
173
+ // return driver;
174
+ // }
175
+ }
0 commit comments