Skip to content

Commit 530d6ac

Browse files
committed
Merge branch 'master' of https://github.com/Sandeep4odesk/tutorials into Sandeep4odesk-master
2 parents 9c1b87d + 4e6d70d commit 530d6ac

3 files changed

Lines changed: 104 additions & 0 deletions

File tree

‎selenium-junit-testng/pom.xml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.baeldung</groupId>
4+
<artifactId>selenium-junit-testng</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
<build>
7+
<sourceDirectory>src</sourceDirectory>
8+
<plugins>
9+
<plugin>
10+
<artifactId>maven-compiler-plugin</artifactId>
11+
<version>3.1</version>
12+
<configuration>
13+
<source>1.8</source>
14+
<target>1.8</target>
15+
</configuration>
16+
</plugin>
17+
</plugins>
18+
</build>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.seleniumhq.selenium</groupId>
22+
<artifactId>selenium-java</artifactId>
23+
<version>2.53.1</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>junit</groupId>
27+
<artifactId>junit</artifactId>
28+
<version>4.8.1</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.testng</groupId>
32+
<artifactId>testng</artifactId>
33+
<version>6.9.10</version>
34+
</dependency>
35+
</dependencies>
36+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.baeldun.selenium.testng;
2+
import static org.testng.Assert.assertEquals;
3+
import static org.testng.Assert.assertNotNull;
4+
5+
import org.openqa.selenium.WebDriver;
6+
import org.openqa.selenium.firefox.FirefoxDriver;
7+
import org.testng.annotations.AfterSuite;
8+
import org.testng.annotations.BeforeSuite;
9+
import org.testng.annotations.Test;
10+
11+
public class TestSeleniumWithTestNG {
12+
13+
private WebDriver webDriver;
14+
private final String url = "http://www.baeldung.com/";
15+
private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
16+
17+
@BeforeSuite
18+
public void setUp() {
19+
webDriver = new FirefoxDriver();
20+
webDriver.get(url);
21+
}
22+
23+
@AfterSuite
24+
public void tearDown() {
25+
webDriver.close();
26+
}
27+
28+
@Test
29+
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
30+
String actualTitleReturned = webDriver.getTitle();
31+
assertNotNull(actualTitleReturned);
32+
assertEquals(expectedTitle, actualTitleReturned);
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.baeldung.selenium.junit;
2+
import static org.junit.Assert.assertEquals;
3+
import static org.junit.Assert.assertNotNull;
4+
5+
import org.junit.After;
6+
import org.junit.Before;
7+
import org.junit.Test;
8+
import org.openqa.selenium.WebDriver;
9+
import org.openqa.selenium.firefox.FirefoxDriver;
10+
11+
public class TestSeleniumWithJUnit {
12+
13+
private WebDriver webDriver;
14+
private final String url = "http://www.baeldung.com/";
15+
private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
16+
17+
@Before
18+
public void setUp() {
19+
webDriver = new FirefoxDriver();
20+
webDriver.get(url);
21+
}
22+
23+
@After
24+
public void tearDown() {
25+
webDriver.close();
26+
}
27+
28+
@Test
29+
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
30+
String actualTitleReturned = webDriver.getTitle();
31+
assertNotNull(actualTitleReturned);
32+
assertEquals(expectedTitle, actualTitleReturned);
33+
}
34+
}

0 commit comments

Comments
 (0)