forked from perfectomobile/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamazon
More file actions
95 lines (63 loc) · 2.41 KB
/
amazon
File metadata and controls
95 lines (63 loc) · 2.41 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.perfectomobile.httpclient.MediaType;
import com.perfectomobile.httpclient.utils.FileUtils;
import com.perfectomobile.selenium.MobileDriver;
import com.perfectomobile.selenium.api.IMobileDevice;
import com.perfectomobile.selenium.api.IMobileDriver;
/**
* JUnit Parameterized Test
*
*/
@RunWith(value = Parameterized.class)
public class AmazonScript {
private String _dev_id;
static MobileDriver driver;
public AmazonScript(String DeviceID) {
this._dev_id = DeviceID;
String host = Constants.PM_CLOUD;
String user = Constants.PM_USER;
String password = Constants.PM_PASSWORD;
driver = new MobileDriver(host, user, password);
}
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {{"D025A0A023920BKQ"}});
}
// The test work on the specific device ID
// This testcase go to united.com , look for specific flight and validate we go
@Test
public void CheckFlight() {
IMobileDevice device = ((IMobileDriver) driver).getDevice(_dev_id);
// Getting the device form Perfecto mobile system, open it and take it to the ready mode (HOME)
device.open();
device.home();
// Define to types of web driver
// 1. DOM - standard web webdriver works with the DOM objects
// 2. Visual Driver - allows to validate that text appear on the screen using visual analysis (OCR).
// This validation is very important and simulate the real user experience.
WebDriver webDriver = device.getDOMDriver ("www.amazon.com");
WebDriver visualDriver = device.getVisualDriver();
visualDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
visualDriver.findElement(By.linkText("Kindle fire HD"));
webDriver.findElement(By.xpath("(//@id=\"twotabsearchtextbox\")[1]")).sendKeys("kindle hdx");
webDriver.findElement(By.xpath("(//INPUT)[2]")).click();
visualDriver.findElement(By.linkText("Kindle Fire HD 7"));
}
@AfterClass
public static void testCleanup() {
driver.quit();
}
}