Last active
September 11, 2020 18:51
-
-
Save bharadwaj-pendyala/01a698bc32fe74e50fcca4ec370fe4de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import org.openqa.selenium.chrome.ChromeDriver; | |
| import org.openqa.selenium.chrome.ChromeDriverService; | |
| import org.openqa.selenium.chrome.ChromeOptions; | |
| import org.openqa.selenium.remote.DesiredCapabilities; | |
| import java.io.File; | |
| public class ChromeDriverManager extends DriverFactory { | |
| private ChromeDriverService chromeService; | |
| @Override | |
| protected void startBrowser() { | |
| if (null == chromeService) { | |
| try { | |
| chromeService = new ChromeDriverService.Builder().usingDriverExecutable(new File("chromedriver")).usingAnyFreePort().build(); | |
| chromeService.start(); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } | |
| @Override | |
| protected void stopBrowser() { | |
| if ((null != chromeService) && chromeService.isRunning()) | |
| chromeService.stop(); | |
| } | |
| @Override | |
| protected void createDriver() { | |
| DesiredCapabilities capabilities = DesiredCapabilities.chrome(); | |
| ChromeOptions options = new ChromeOptions(); | |
| options.addArguments("test-type"); | |
| capabilities.setCapability(ChromeOptions.CAPABILITY, options); | |
| driver = new ChromeDriver(chromeService, capabilities); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment