diff --git a/pom.xml b/pom.xml
index 32c4583..778ba6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1 +1,48 @@
-
4.0.0
com.movoto.tests
selenium-example
1.0-SNAPSHOT
junit
junit
4.12
test
org.seleniumhq.selenium
selenium-java
3.0.1
org.seleniumhq.selenium
selenium-chrome-driver
3.0.1
org.seleniumhq.selenium
htmlunit-driver
2.23.2
org.seleniumhq.selenium
selenium-firefox-driver
3.0.1
\ No newline at end of file
+
+
+ 4.0.0
+
+ com.movoto.tests
+ selenium-example
+ 1.0-SNAPSHOT
+
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 4.11.0
+
+
+
+ org.seleniumhq.selenium
+ selenium-chrome-driver
+ 4.11.0
+
+
+
+ org.seleniumhq.selenium
+ htmlunit-driver
+ 2.70.0
+
+
+
+ org.seleniumhq.selenium
+ selenium-firefox-driver
+ 4.11.0
+
+
+
+
+
+
+
diff --git a/src/test/java/org/movoto/selenium/example/ChromeDriverTest.java b/src/test/java/org/movoto/selenium/example/ChromeDriverTest.java
index 0fe8b02..7650cb4 100644
--- a/src/test/java/org/movoto/selenium/example/ChromeDriverTest.java
+++ b/src/test/java/org/movoto/selenium/example/ChromeDriverTest.java
@@ -1,28 +1,18 @@
-package org.movoto.selenium.example;
-
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
-import org.openqa.selenium.firefox.MarionetteDriver;
-import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.IOException;
import java.util.List;
-import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertTrue;
-/**
- * Created by haozuo on 3/22/16.
- */
public class ChromeDriverTest {
private String testUrl;
@@ -35,47 +25,44 @@ public void prepare() {
"webdriver.chrome.driver",
"webdriver/chromedriver");
- testUrl = "https://leftstick.github.io/";
+ testUrl = "https://www.youtube.com/";
- // Create a new instance of the Chrome driver
- // Notice that the remainder of the code relies on the interface,
- // not the implementation.
+ // Initialize ChromeDriver
driver = new ChromeDriver();
- //maximize window
+ // Maximize window
driver.manage().window().maximize();
- // And now use this to visit myBlog
- // Alternatively the same thing can be done like this
- // driver.navigate().to(testUrl);
+ // Navigate to test URL
driver.get(testUrl);
}
- @Test
- public void testTitle() throws IOException {
-
- // Find elements by attribute lang="READ_MORE_BTN"
- List elements = driver
- .findElements(By.cssSelector("[lang=\"READ_MORE_BTN\"]"));
-
- //Click the selected button
- elements.get(0).click();
-
-
- assertTrue("The page title should be chagned as expected",
- (new WebDriverWait(driver, 5))
- .until(new ExpectedCondition() {
- public Boolean apply(WebDriver d) {
- return d.getTitle().equals("我眼中软件工程人员该有的常识");
- }
- })
- );
+ @Test
+public void testTitle() throws IOException {
+ // Find elements by attribute lang="READ_MORE_BTN"
+ List elements = driver
+ .findElements(By.cssSelector("[lang=\"READ_MORE_BTN\"]"));
+
+ // Click the selected button
+ elements.get(0).click();
+
+ // Wait for the page title to change and assert it
+ assertTrue("The page title should be changed as expected",
+ (new WebDriverWait(driver, java.time.Duration.ofSeconds(5)))
+ .until(new ExpectedCondition() {
+ public Boolean apply(WebDriver d) {
+ return d.getTitle().equals("我眼中软件工程人员该有的常识");
+ }
+ })
+ );
+}
- }
@After
public void teardown() throws IOException {
- driver.quit();
+ // Check if driver is not null before quitting
+ if (driver != null) {
+ driver.quit();
+ }
}
-
}
diff --git a/src/test/java/org/movoto/selenium/example/FirefoxTest.java b/src/test/java/org/movoto/selenium/example/FirefoxTest.java
deleted file mode 100644
index 761b7aa..0000000
--- a/src/test/java/org/movoto/selenium/example/FirefoxTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.movoto.selenium.example;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Dimension;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.htmlunit.HtmlUnitDriver;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Created by haozuo on 3/23/16.
- */
-public class FirefoxTest {
-
- private String testUrl;
- private WebDriver driver;
-
- @Before
- public void prepare() {
-
- testUrl = "https://leftstick.github.io/";
-
- System.setProperty("webdriver.gecko.driver","webdriver/geckodriver");
-
- // Create a new instance of the Chrome driver
- // Notice that the remainder of the code relies on the interface,
- // not the implementation.
- driver = new FirefoxDriver();
-
- // And now use this to visit myBlog
- // Alternatively the same thing can be done like this
- // driver.navigate().to(testUrl);
- driver.get(testUrl);
- }
-
- @Test
- public void testTitle() throws IOException {
-
- // Find elements by attribute lang="READ_MORE_BTN"
- List elements = driver
- .findElements(By.cssSelector("[lang=\"READ_MORE_BTN\"]"));
-
- //Click the selected button
- elements.get(0).click();
-
-
- assertTrue("The page title should be chagned as expected",
- (new WebDriverWait(driver, 3))
- .until(new ExpectedCondition() {
- public Boolean apply(WebDriver d) {
- return d.getTitle().equals("我眼中软件工程人员该有的常识");
- }
- })
- );
- }
-
- @After
- public void teardown() throws IOException {
- driver.quit();
- }
-
-}
diff --git a/src/test/java/org/movoto/selenium/example/SafariTest.java b/src/test/java/org/movoto/selenium/example/SafariTest.java
deleted file mode 100644
index e6405e1..0000000
--- a/src/test/java/org/movoto/selenium/example/SafariTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.movoto.selenium.example;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openqa.selenium.*;
-import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.interactions.Mouse;
-import org.openqa.selenium.safari.SafariDriver;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Created by haozuo on 3/22/16.
- */
-public class SafariTest {
-
- private String testUrl;
- private WebDriver driver;
-
- @Before
- public void prepare() {
-
- testUrl = "https://leftstick.github.io/";
-
- driver = new SafariDriver();
- driver.manage().window().maximize();
- driver.get(testUrl);
- }
-
- @Test
- public void testTitle() throws IOException {
-
- // Find elements by attribute lang="READ_MORE_BTN"
- List elements = driver
- .findElements(By.cssSelector("[lang=\"READ_MORE_BTN\"]"));
-
- //Click the selected button
- elements.get(0).click();
-
-
- assertTrue("The page title should be chagned as expected",
- (new WebDriverWait(driver, 5))
- .until(new ExpectedCondition() {
- public Boolean apply(WebDriver d) {
- return d.getTitle().equals("我眼中软件工程人员该有的常识");
- }
- })
- );
-
- }
-
- @After
- public void teardown() throws IOException {
- driver.quit();
- }
-
-}