-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaSafariBrowserStack.java
More file actions
64 lines (46 loc) · 2.18 KB
/
JavaSafariBrowserStack.java
File metadata and controls
64 lines (46 loc) · 2.18 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
package BrowserStack;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import Common.Waiter;
import java.net.URL;
public class JavaSafariBrowserStack {
public static final String USERNAME = "user";
public static final String AUTOMATE_KEY = "key";
public static final String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";
public static void main(String[] args) throws Exception {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browser", "safari");
caps.setCapability("os", "OS X");
caps.setCapability("browserstack.debug", "true");
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
String expectedTitle = "Dashboard";
String actualTitle = "";
String baseurl = "https://www.browserstack.com/";
Waiter _waiter = new Waiter(driver);
//Step 1: Open the BrowserStack site
driver.get(baseurl);
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");
}
driver.quit();
}
}