Last active
October 24, 2016 13:21
-
-
Save ujwalp1994/66520c1be987dfc9998d056f3c075dcc 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.WebDriver; | |
import org.openqa.selenium.chrome.ChromeOptions; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import java.io.File; | |
import java.net.URL; | |
public class ExtensionsChrome { | |
//======= Set up automate with username and access key======= | |
public static final String USERNAME = "<USERNAME>"; | |
public static final String AUTOMATE_KEY = "<ACCESS_KEY>"; | |
public static final String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud-us.browserstack.com/wd/hub"; | |
public static void main(String[] args) throws Exception { | |
//======= Add OS /Browser capabilites======= | |
DesiredCapabilities caps = new DesiredCapabilities(); | |
caps.setCapability("browserName", "Chrome"); | |
caps.setCapability("browser_version", "48.0"); | |
caps.setCapability("os", "Windows"); | |
caps.setCapability("os_version", "10"); | |
//======= Set the ChromeOptions to install the extensions ======= | |
ChromeOptions options = new ChromeOptions(); | |
options.addExtensions(new File("Path_to_Chrome_extension.crx")); | |
caps.setCapability(ChromeOptions.CAPABILITY, options); | |
WebDriver driver = new RemoteWebDriver(new URL(URL), caps); | |
driver.get("http://www.google.com"); | |
Thread.sleep(50000); | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment