-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathexecuteJavaCode.java
More file actions
40 lines (27 loc) · 1.05 KB
/
executeJavaCode.java
File metadata and controls
40 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import com.perfectomobile.selenium.MobileDriver;
import com.perfectomobile.selenium.api.IMobileDevice;
import com.perfectomobile.selenium.api.IMobileWebDriver;
public class executeJavaCode {
public static void main(String[] args) {
MobileDriver driver = new MobileDriver(Constants.PM_CLOUD,Constants.PM_USER,Constants.PM_PASSWORD);
System.out.println("Script started");
try {
IMobileDevice device = driver.getDevice(Constants.DEVICE);
device.open();
device.home();
WebDriver webDriver = device.getDOMDriver ("cnnmobile.com");
webDriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
webDriver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
((IMobileWebDriver) webDriver).executeScript("alert('Perfecto Mobile');");
} catch (Exception e) {
e.printStackTrace();
// onError(connector.getDevice(Constants.DEVICE););
} finally {
driver.quit();
}
System.out.println("Script ended");
}
}