-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2025-01-09 17:12:39.806169 new snippets
- Loading branch information
1 parent
5bfc401
commit bde9d04
Showing
22 changed files
with
1,194 additions
and
784 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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//date: 2025-01-09T17:06:25Z | ||
//url: https://api.github.com/gists/780c2128c6c590576e7997dbdd4cfe42 | ||
//owner: https://api.github.com/users/borodicht | ||
|
||
package ui.drivers; | ||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
import org.openqa.selenium.firefox.FirefoxDriver; | ||
import org.openqa.selenium.firefox.FirefoxOptions; | ||
|
||
public class DriverManager { | ||
|
||
private static ThreadLocal <WebDriver> driver = new ThreadLocal<>(); | ||
|
||
private DriverManager() {}; | ||
|
||
public static WebDriver getDriver() { | ||
if (driver.get() == null) { | ||
iniztialiazeDriver(); | ||
} | ||
return driver.get(); | ||
} | ||
|
||
private static void iniztialiazeDriver() { | ||
String browser = System.getProperty("browser", "chrome"); | ||
|
||
switch (browser.toLowerCase()) { | ||
case "chrome": | ||
ChromeOptions options = new ChromeOptions(); | ||
options.addArguments("--headless"); | ||
driver.set(new ChromeDriver(options)); | ||
case "firefox": | ||
FirefoxOptions options1 = new FirefoxOptions(); | ||
options1.addArguments("--headless"); | ||
driver.set(new FirefoxDriver(options1)); | ||
default: | ||
throw new IllegalArgumentException(browser); | ||
} | ||
} | ||
|
||
public void tearDown() { | ||
if(driver.get() != null) { | ||
driver.get().quit(); | ||
driver.remove(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.