Modifying methods in test files
This commit is contained in:
parent
fe59ea2923
commit
c3a340e0ec
@ -6,9 +6,8 @@ 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";
|
||||
|
||||
private String url = "http://www.baeldung.com/";
|
||||
|
||||
public SeleniumExample() {
|
||||
webDriver = new FirefoxDriver();
|
||||
webDriver.get(url);
|
||||
@ -18,12 +17,8 @@ public class SeleniumExample {
|
||||
webDriver.close();
|
||||
}
|
||||
|
||||
public String getActualTitle() {
|
||||
public String getTitle() {
|
||||
return webDriver.getTitle();
|
||||
}
|
||||
|
||||
public String getExpectedTitle() {
|
||||
return expectedTitle;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.junit.Test;
|
||||
public class TestSeleniumWithJUnit {
|
||||
|
||||
private SeleniumExample seleniumExample;
|
||||
private String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@ -23,8 +24,8 @@ public class TestSeleniumWithJUnit {
|
||||
|
||||
@Test
|
||||
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
|
||||
String expectedTitle = seleniumExample.getExpectedTitle();
|
||||
String actualTitle = seleniumExample.getActualTitle();
|
||||
String actualTitle = seleniumExample.getTitle();
|
||||
assertNotNull(actualTitle);
|
||||
assertEquals(actualTitle, expectedTitle);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.testng.annotations.Test;
|
||||
public class TestSeleniumWithTestNG {
|
||||
|
||||
private SeleniumExample seleniumExample;
|
||||
private String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
|
||||
|
||||
@BeforeSuite
|
||||
public void setUp() {
|
||||
@ -23,8 +24,8 @@ public class TestSeleniumWithTestNG {
|
||||
|
||||
@Test
|
||||
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
|
||||
String expectedTitle = seleniumExample.getExpectedTitle();
|
||||
String actualTitle = seleniumExample.getActualTitle();
|
||||
String actualTitle = seleniumExample.getTitle();
|
||||
assertNotNull(actualTitle);
|
||||
assertEquals(actualTitle, expectedTitle);
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
package com.baeldun.selenium.testng;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.testng.annotations.AfterSuite;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestSeleniumWithTestNG {
|
||||
|
||||
private WebDriver webDriver;
|
||||
private final String url = "http://www.baeldung.com/";
|
||||
private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
|
||||
|
||||
@BeforeSuite
|
||||
public void setUp() {
|
||||
webDriver = new FirefoxDriver();
|
||||
webDriver.get(url);
|
||||
}
|
||||
|
||||
@AfterSuite
|
||||
public void tearDown() {
|
||||
webDriver.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
|
||||
String actualTitleReturned = webDriver.getTitle();
|
||||
assertNotNull(actualTitleReturned);
|
||||
assertEquals(expectedTitle, actualTitleReturned);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.baeldung.selenium.junit;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
|
||||
public class TestSeleniumWithJUnit {
|
||||
|
||||
private WebDriver webDriver;
|
||||
private final String url = "http://www.baeldung.com/";
|
||||
private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
webDriver = new FirefoxDriver();
|
||||
webDriver.get(url);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
webDriver.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
|
||||
String actualTitleReturned = webDriver.getTitle();
|
||||
assertNotNull(actualTitleReturned);
|
||||
assertEquals(expectedTitle, actualTitleReturned);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user