Skip to content

Commit be3797a

Browse files
committed
- Updated to the latest WebDriverManager version
- Edge browser support added
1 parent a22d66a commit be3797a

File tree

7 files changed

+317
-0
lines changed

7 files changed

+317
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.idea/
2+
/target/

pom.xml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.qaffe</groupId>
8+
<artifactId>webdrivermanager-demo</artifactId>
9+
<version>1.1.0</version>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>org.testng</groupId>
14+
<artifactId>testng</artifactId>
15+
<version>7.4.0</version>
16+
<scope>test</scope>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.seleniumhq.selenium</groupId>
20+
<artifactId>selenium-java</artifactId>
21+
<version>3.141.59</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>io.github.bonigarcia</groupId>
25+
<artifactId>webdrivermanager</artifactId>
26+
<version>4.4.3</version>
27+
</dependency>
28+
</dependencies>
29+
30+
<build>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-compiler-plugin</artifactId>
35+
<version>3.2</version>
36+
<configuration>
37+
<source>1.8</source>
38+
<target>1.8</target>
39+
</configuration>
40+
</plugin>
41+
</plugins>
42+
</build>
43+
44+
</project>
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.qacaffe;
2+
3+
import io.github.bonigarcia.wdm.WebDriverManager;
4+
import org.openqa.selenium.By;
5+
import org.openqa.selenium.Keys;
6+
import org.openqa.selenium.WebDriver;
7+
import org.openqa.selenium.chrome.ChromeDriver;
8+
import org.testng.Assert;
9+
import org.testng.annotations.AfterTest;
10+
import org.testng.annotations.BeforeTest;
11+
import org.testng.annotations.Test;
12+
13+
/**
14+
* @author Rahul R on 1/11/2021
15+
* @version 1.1.0
16+
*/
17+
public class TestChrome {
18+
19+
private WebDriver driver;
20+
21+
@BeforeTest
22+
public void setup() {
23+
24+
WebDriverManager.chromedriver().setup();
25+
driver = new ChromeDriver();
26+
27+
driver.manage().window().maximize();
28+
29+
driver.get("https://www.google.com");
30+
31+
}
32+
33+
@Test
34+
public void openQACaffe_chrome() throws InterruptedException {
35+
36+
driver.findElement(By.name("q")).sendKeys("QACaffe RahulR");
37+
38+
driver.findElement(By.name("q")).sendKeys(Keys.ENTER);
39+
40+
Thread.sleep(5000);
41+
42+
driver.findElement(By.xpath("//h3[text()='QACaffe By RahulR']")).click();
43+
44+
Thread.sleep(5000);
45+
46+
Assert.assertEquals(driver.getTitle(), "QACaffe By RahulR",
47+
"Failed to open the clicked site.");
48+
49+
}
50+
51+
@AfterTest
52+
public void teardown() {
53+
driver.quit();
54+
}
55+
56+
}
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.qacaffe;
2+
3+
import io.github.bonigarcia.wdm.WebDriverManager;
4+
import org.openqa.selenium.By;
5+
import org.openqa.selenium.Keys;
6+
import org.openqa.selenium.WebDriver;
7+
import org.openqa.selenium.chrome.ChromeDriver;
8+
import org.openqa.selenium.edge.EdgeDriver;
9+
import org.testng.Assert;
10+
import org.testng.annotations.AfterTest;
11+
import org.testng.annotations.BeforeTest;
12+
import org.testng.annotations.Test;
13+
14+
/**
15+
* @author Rahul R on 1/11/2021
16+
* @version 1.1.0
17+
*/
18+
public class TestEdge {
19+
20+
private WebDriver driver;
21+
22+
@BeforeTest
23+
public void setup() {
24+
25+
WebDriverManager.edgedriver().setup();
26+
driver = new EdgeDriver();
27+
28+
driver.manage().window().maximize();
29+
30+
driver.get("https://www.google.com");
31+
32+
}
33+
34+
@Test
35+
public void openQACaffe_edge() throws InterruptedException {
36+
37+
driver.findElement(By.name("q")).sendKeys("QACaffe RahulR");
38+
39+
driver.findElement(By.name("q")).sendKeys(Keys.ENTER);
40+
41+
Thread.sleep(5000);
42+
43+
driver.findElement(By.xpath("//h3[text()='QACaffe By RahulR']")).click();
44+
45+
Thread.sleep(5000);
46+
47+
Assert.assertEquals(driver.getTitle(), "QACaffe By RahulR",
48+
"Failed to open the clicked site.");
49+
50+
}
51+
52+
@AfterTest
53+
public void teardown() {
54+
driver.quit();
55+
}
56+
57+
}
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.qacaffe;
2+
3+
import io.github.bonigarcia.wdm.WebDriverManager;
4+
import org.openqa.selenium.By;
5+
import org.openqa.selenium.Keys;
6+
import org.openqa.selenium.WebDriver;
7+
import org.openqa.selenium.WebElement;
8+
import org.openqa.selenium.firefox.FirefoxDriver;
9+
import org.testng.Assert;
10+
import org.testng.annotations.AfterTest;
11+
import org.testng.annotations.BeforeTest;
12+
import org.testng.annotations.Test;
13+
14+
/**
15+
* @author Rahul R on 1/11/2021
16+
* @version 1.1.0
17+
*/
18+
public class TestFirefox {
19+
20+
private WebDriver driver;
21+
22+
@BeforeTest
23+
public void setup() {
24+
25+
WebDriverManager.firefoxdriver().setup();
26+
driver = new FirefoxDriver();
27+
28+
driver.manage().window().maximize();
29+
30+
driver.get("https://www.google.com");
31+
32+
}
33+
34+
@Test
35+
public void openQACaffe_firefox() throws InterruptedException {
36+
37+
driver.findElement(By.name("q")).sendKeys("QACaffe RahulR");
38+
39+
driver.findElement(By.name("q")).sendKeys(Keys.ENTER);
40+
41+
Thread.sleep(5000);
42+
43+
driver.findElement(By.xpath("//h3[text()='QACaffe By RahulR']/parent::a")).click();
44+
45+
Thread.sleep(5000);
46+
47+
Assert.assertEquals(driver.getTitle(), "QACaffe By RahulR",
48+
"Failed to open the clicked site.");
49+
}
50+
51+
@AfterTest
52+
public void teardown() {
53+
driver.quit();
54+
}
55+
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.qacaffe;
2+
3+
import io.github.bonigarcia.wdm.WebDriverManager;
4+
import org.openqa.selenium.By;
5+
import org.openqa.selenium.Keys;
6+
import org.openqa.selenium.WebDriver;
7+
import org.openqa.selenium.ie.InternetExplorerDriver;
8+
import org.testng.Assert;
9+
import org.testng.annotations.AfterTest;
10+
import org.testng.annotations.BeforeTest;
11+
import org.testng.annotations.Test;
12+
13+
/**
14+
* @author Rahul R on 1/11/2021
15+
* @version 1.1.0
16+
*/
17+
public class TestIExplorer {
18+
19+
private WebDriver driver;
20+
21+
@BeforeTest
22+
public void setup() {
23+
24+
WebDriverManager.iedriver().setup();
25+
WebDriverManager.iedriver().arch32().setup();
26+
driver = new InternetExplorerDriver();
27+
28+
driver.manage().window().maximize();
29+
30+
driver.get("https://www.google.com");
31+
32+
}
33+
34+
@Test
35+
public void openQACaffe_iExplorer() throws InterruptedException {
36+
37+
System.err.println("As Microsoft already closed the IE Project, there might be chances the code may fail.");
38+
39+
driver.findElement(By.name("q")).sendKeys("QACaffe RahulR");
40+
41+
driver.findElement(By.name("q")).sendKeys(Keys.ENTER);
42+
43+
Thread.sleep(10000);
44+
45+
driver.findElement(By.xpath("//h3[text()='QACaffe By RahulR']/parent::a")).click();
46+
47+
Thread.sleep(5000);
48+
49+
Assert.assertEquals(driver.getTitle(), "QACaffe By RahulR",
50+
"Failed to open the clicked site.");
51+
}
52+
53+
@AfterTest
54+
public void teardown() {
55+
driver.quit();
56+
}
57+
58+
}

testng.xml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<suite name="WebDriverManager Demo" verbose="10" parallel="false" thread-count="1">
3+
4+
<test name="Open QACaffe in Google Chrome browser.">
5+
<classes>
6+
<class name="com.qacaffe.TestChrome">
7+
<methods>
8+
<include name="openQACaffe_chrome"/>
9+
</methods>
10+
</class>
11+
</classes>
12+
</test>
13+
14+
<test name="Open QACaffe in MS Edge browser.">
15+
<classes>
16+
<class name="com.qacaffe.TestEdge">
17+
<methods>
18+
<include name="openQACaffe_edge"/>
19+
</methods>
20+
</class>
21+
</classes>
22+
</test>
23+
24+
<test name="Open QACaffe in Mozilla Firefox browser.">
25+
<classes>
26+
<class name="com.qacaffe.TestFirefox">
27+
<methods>
28+
<include name="openQACaffe_firefox"/>
29+
</methods>
30+
</class>
31+
</classes>
32+
</test>
33+
34+
<test name="Open QACaffe in Internet Explorer browser.">
35+
<classes>
36+
<class name="com.qacaffe.TestIExplorer">
37+
<methods>
38+
<include name="openQACaffe_iExplorer"/>
39+
</methods>
40+
</class>
41+
</classes>
42+
</test>
43+
44+
</suite>

0 commit comments

Comments
 (0)