Skip to content

Instantly share code, notes, and snippets.

@sauceaaron
Last active October 16, 2018 19:04
Show Gist options
  • Save sauceaaron/6a94f4cb6193ad4c61faf6c873354a2a to your computer and use it in GitHub Desktop.
Save sauceaaron/6a94f4cb6193ad4c61faf6c873354a2a to your computer and use it in GitHub Desktop.
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
public class SimpleSauceTest
{
@Test
public void test() throws MalformedURLException
{
String SAUCE_URL = "https://ondemand.saucelabs.com/wd/hub";
String SAUCE_USERNAME = System.getenv("SAUCE_USERNAME");
String SAUCE_ACCESS_KEY = System.getenv("SAUCE_ACCESS_KEY");
String SELENIUM_PLATFORM = System.getenv("SELENIUM_PLATFORM");
String SELENIUM_BROWSER = System.getenv("SELENIUM_BROWSER");
String SELENIUM_VERSION = System.getenv("SELENIUM_VERSION");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("username", SAUCE_USERNAME);
capabilities.setCapability("accessKey", SAUCE_ACCESS_KEY);
capabilities.setCapability("platform", SELENIUM_PLATFORM);
capabilities.setCapability("browser", SELENIUM_BROWSER);
capabilities.setCapability("version", SELENIUM_VERSION);
RemoteWebDriver driver = new RemoteWebDriver(new URL(SAUCE_URL), capabilities);
driver.get("https://saucelabs.com");
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment