-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyClass.java
More file actions
95 lines (66 loc) · 3.69 KB
/
MyClass.java
File metadata and controls
95 lines (66 loc) · 3.69 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
94
95
package newpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.HashMap;
import org.openqa.selenium.By;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
public class MyClass {
public static void main(String[] arg) {
final String USERNAME = "johnjose_pjx5Yk";
final String AUTOMATE_KEY = "7zNR8G31jxjoyBz7EVhZ";
String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";
MutableCapabilities capabilities = new MutableCapabilities();
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("browserVersion", "latest");
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("os", "Windows");
browserstackOptions.put("osVersion", "11");
browserstackOptions.put("projectName", "Sample sandbox project");
browserstackOptions.put("buildName", "Build #1");
browserstackOptions.put("sessionName", "My First Test");
capabilities.setCapability("bstack:options", browserstackOptions);
// WebDriver driver = new ChromeDriver();
// driver.get("https://www.amazon.in/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.in%2F%3Fref_%3Dnav_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=inflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&");
WebDriver driver = null;
try {
driver = new RemoteWebDriver(new URL(URL), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.get("https://www.amazon.in/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.in%2F%3Fref_%3Dnav_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=inflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&");
WebElement txtbx_username = driver.findElement(By.id("ap_email"));
txtbx_username.sendKeys("testamazon520@gmail.com");
WebElement button_continue = driver.findElement(By.id("continue"));
button_continue.click();
WebElement txtbx_password = driver.findElement(By.id("ap_password"));
txtbx_password.sendKeys("br0wserSt@ck");
WebElement button_signin = driver.findElement(By.id("signInSubmit"));
button_signin.click();
// WebElement warning_message = driver.findElement(By.className("a-list-item"));
// String warning_incorrect_password = "Your password is incorrect";
String expected_URL1 = "https://www.amazon.in/ap/signin";
String expected_URL2 = "https://www.amazon.in/?ref_=nav_signin";
String actual_URL = driver.getCurrentUrl();
if (expected_URL1.equals(actual_URL) || expected_URL2.equals(actual_URL) ) {
System.out.println("Login Successful");
System.out.println(actual_URL);
System.out.println(URL);
}
else {
System.out.println("Login Failed");
System.out.println(actual_URL);
System.out.println(URL);
}
driver.quit();
// System.setProperty("webdriver.chrome.driver", "C:\\Users\\JohnJose\\browserdrivers");
}
}