-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathexgrid.java
More file actions
84 lines (77 loc) · 3.02 KB
/
Copy pathexgrid.java
File metadata and controls
84 lines (77 loc) · 3.02 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
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class seleniumex {
public static void main(String[] args) throws InterruptedException, MalformedURLException {
seleniumex selObj = new seleniumex();
selObj.seltestcase1();
selObj.seltestcase2();
selObj.loginBrowser();
selObj.seltestcase01();
}
public void seltestcase01() throws InterruptedException, MalformedURLException {
String URL = "https://www.google.com/";
String Node = "http://192.168.32.1:4444/wd/hub";
DesiredCapabilities cap = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL(Node), cap);
driver.navigate().to(URL);
Thread.sleep(5000);
driver.quit();
}
public void seltestcase1() throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "/Users/ravi/Downloads/geckodriver");
WebDriver driver=new FirefoxDriver();
driver.get("https://www.google.com/");
System.out.print(driver.getTitle());
if(driver.getPageSource().contains("I'm Feeling Lucky")) {
System.out.println("Test case1 success");
}
else {
System.out.println("Test case1 failed");
}
Thread.sleep(500);
driver.close();
}
public void seltestcase2() throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "/Users/ravi/Downloads/geckodriver");
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
WebDriver driver = new FirefoxDriver(firefoxOptions);
driver.get("https://www.google.com/");
System.out.print(driver.getTitle());
if(driver.getPageSource().contains("I'm Feeling Lucky")) {
System.out.println("Test case1 success");
}
else {
System.out.println("Test case1 failed");
}
Thread.sleep(500);
driver.close();
}
public void loginBrowser() {
System.setProperty("webdriver.gecko.driver", "/Users/ravi/Downloads/geckodriver");
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
WebDriver driver = new FirefoxDriver(firefoxOptions);
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().pageLoadTimeout(15,TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("http://www.facebook.com");
driver.findElement(By.name("email")).sendKeys("Your Facebook Email Id");
driver.findElement(By.name("pass")).sendKeys("Your Password");
driver.findElement(By.id("loginbutton")).click();
driver.close();
}
}