Created
March 7, 2018 04:23
-
-
Save DylanLacey/52c8f0bfae0daca6658f2690464898b3 to your computer and use it in GitHub Desktop.
Encoding Usernames for RemoteWebDriver
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
// Add to the end of your imports | |
import java.net.URLEncoder; | |
public String username = "someone@company"; | |
public String accesskey = "abc123-defgh4312-deftg"; | |
// Inside your driver creation method | |
String seleniumServer = "ondemand.saucelabs.com:443"; | |
String authenticatedURL = "https://" + URLEncoder.encode(username) + ":" + accesskey + "@" + seleniumUrl + "/wd/hub"; | |
URL seleniumURL = new URL(authenticatedURL); | |
// Can be removed entirely once you can connect (or replaced with a call to your logger) | |
System.out.println(seleniumURL.toString()); | |
// Launch remote browser and set it as the current thread | |
webDriver.set(new RemoteWebDriver( | |
seleniumURL, | |
capabilities)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment