Created
March 15, 2021 13:42
-
-
Save muditlambda/e85a50df9a351b40b066e972d0075796 to your computer and use it in GitHub Desktop.
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
package org.testnggroup; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeOptions; | |
import org.openqa.selenium.edge.EdgeOptions; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.firefox.FirefoxOptions; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import org.openqa.selenium.safari.SafariOptions; | |
public class Helper { | |
protected static ThreadLocal<RemoteWebDriver> driver = new ThreadLocal<>(); | |
public static String remote_url = "http://localhost:4444/wd/hub"; | |
public void setupThread(String browserName) throws MalformedURLException | |
{ | |
if(browserName.equalsIgnoreCase("chrome")) | |
{ | |
ChromeOptions options = new ChromeOptions(); | |
driver.set(new RemoteWebDriver(new URL(remote_url), options)); | |
} | |
else if (browserName.equalsIgnoreCase("firefox")) | |
{ | |
FirefoxOptions options = new FirefoxOptions(); | |
driver.set(new RemoteWebDriver(new URL(remote_url), options)); | |
} | |
} | |
public WebDriver getDriver() | |
{ | |
return driver.get(); | |
} | |
public void tearDownDriver() | |
{ | |
getDriver().quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment