-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaLocalSafariDriver.java
More file actions
71 lines (53 loc) · 2.33 KB
/
JavaLocalSafariDriver.java
File metadata and controls
71 lines (53 loc) · 2.33 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
import Common.Waiter;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.safari.SafariOptions;
public class JavaLocalSafariDriver {
public static void main(String[] args) {
// declaration and instantiation of objects/variables
WebDriver driver ;
System.setProperty("webdriver.safari.driver","/usr/bin/safaridriver");
SafariOptions options = new SafariOptions();
options.setUseCleanSession(true);
driver = new SafariDriver(options);
String expectedTitle = "Dashboard";
String actualTitle = "";
Waiter _waiter = new Waiter(driver);
try
{
//Step 1: Open the BrowserStack site
driver.get("https://www.browserstack.com/");
driver.manage().window().maximize();
_waiter.waitForMe(By.linkText("Sign in"), 5);
//Step 2: Search for Sign In link and click on it
driver.findElement(By.linkText("Sign in")).click();
_waiter.waitForMe(By.id("user_email_login"), 5);
//Step 3: Enter the email and password and click on Sign in button
driver.findElement(By.id("user_email_login")).sendKeys("email");
driver.findElement(By.id("user_password")).sendKeys("password");
driver.findElement(By.id("user_submit")).click();
_waiter.waitForMe(By.xpath("//*[@id=\"rf-browsers\"]/div/div[2]/div[4]/ul/li[1]/a"), 5);
//Step 5: Select the browser you want to open live session for and click on it
driver.findElement(By.xpath("//*[@id=\"rf-browsers\"]/div/div[2]/div[4]/ul/li[1]/a")).click();
_waiter.waitForMe(By.id("dock"), 10);
actualTitle = driver.getTitle();
//Step 6: Check whether the live session was successful by checking the title of the Live session page
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
}
catch(Exception e)
{
System.out.println("Exception" + e);
}
finally{
//close Chrome driver
driver.quit();
}
// exit the program explicitly
System.exit(0);
}
}