Merge branch 'master' of https://github.com/Sandeep4odesk/tutorials into Sandeep4odesk-master
This commit is contained in:
commit
162936f00f
@ -0,0 +1,29 @@
|
||||
package main.java.com.baeldung.selenium;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
|
||||
public class SeleniumExample {
|
||||
|
||||
private WebDriver webDriver;
|
||||
private final String url = "http://www.baeldung.com/";
|
||||
private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
|
||||
|
||||
public SeleniumExample() {
|
||||
webDriver = new FirefoxDriver();
|
||||
webDriver.get(url);
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
webDriver.close();
|
||||
}
|
||||
|
||||
public String getActualTitle() {
|
||||
return webDriver.getTitle();
|
||||
}
|
||||
|
||||
public String getExpectedTitle() {
|
||||
return expectedTitle;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package test.java.com.baeldung.selenium.junit;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import main.java.com.baeldung.selenium.SeleniumExample;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestSeleniumWithJUnit {
|
||||
|
||||
private SeleniumExample seleniumExample;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
seleniumExample = new SeleniumExample();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
seleniumExample.closeWindow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
|
||||
String expectedTitle = seleniumExample.getExpectedTitle();
|
||||
String actualTitle = seleniumExample.getActualTitle();
|
||||
assertEquals(actualTitle, expectedTitle);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package test.java.com.baeldung.selenium.testng;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import main.java.com.baeldung.selenium.SeleniumExample;
|
||||
|
||||
import org.testng.annotations.AfterSuite;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestSeleniumWithTestNG {
|
||||
|
||||
private SeleniumExample seleniumExample;
|
||||
|
||||
@BeforeSuite
|
||||
public void setUp() {
|
||||
seleniumExample = new SeleniumExample();
|
||||
}
|
||||
|
||||
@AfterSuite
|
||||
public void tearDown() {
|
||||
seleniumExample.closeWindow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
|
||||
String expectedTitle = seleniumExample.getExpectedTitle();
|
||||
String actualTitle = seleniumExample.getActualTitle();
|
||||
assertEquals(actualTitle, expectedTitle);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user