Last active
November 15, 2016 06:56
-
-
Save ujwalp1994/321b742a06f724adbc5215781a8617ea 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.firefox.FirefoxProfile; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import java.io.File; | |
import java.net.URL; | |
public class AddOnsFirefox { | |
//======= 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", "Firefox"); | |
caps.setCapability("browser_version", "45.0"); | |
caps.setCapability("os", "Windows"); | |
caps.setCapability("os_version", "10"); | |
//======= Set the FirefoxProfile to install the extensions ======= | |
FirefoxProfile firefoxProfile = new FirefoxProfile(); | |
firefoxProfile.addExtension(new File("<path to extension>.xpi")); | |
caps.setCapability(FirefoxDriver.PROFILE, firefoxProfile); | |
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