-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java use Base Test class where possible (#1384)
* use BaseTest in Java example code where possible * fix CI failure by adding wait [deploy site]
- Loading branch information
1 parent
49b073e
commit 1722cc5
Showing
17 changed files
with
408 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
package dev.selenium; | ||
|
||
import java.time.Duration; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.firefox.GeckoDriverService; | ||
import org.openqa.selenium.remote.service.DriverService; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
public class BaseTest { | ||
public WebDriver driver; | ||
|
||
@BeforeAll | ||
public static void defaultLogging() { | ||
System.setProperty(GeckoDriverService.GECKO_DRIVER_LOG_PROPERTY, DriverService.LOG_NULL); | ||
} | ||
|
||
public WebElement getLocatedElement(WebDriver driver, By by) { | ||
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); | ||
return wait.until(d -> driver.findElement(by)); | ||
} | ||
|
||
@AfterEach | ||
public void quit() { | ||
driver.quit(); | ||
if (driver != null) { | ||
driver.quit(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.