How to set up SauceLabs for TestNg Java

  • 16 October 2021
  • 0 replies


Can someone please help me to figure out how to set up saucelabs for testNg on Java? I’ve tried different guides, and it’s always different variations of set up, here's one of the examples that didn't work for me

public void init() throws MalformedURLException {
MutableCapabilities sauceOpts = new MutableCapabilities();
sauceOpts.setCapability("username", "oauth-xxxxxx.yyyyyy-51awdfsa");
sauceOpts.setCapability("accesskey", "xxxxx-32b1-4c4d-ac70-yyyyyyyyy");

DesiredCapabilities options = new DesiredCapabilities();
options.setCapability("sauce:options", "sauceOpts");
options.setCapability("browserVersion", "latest");
options.setCapability("platformName", "windows 10");

Webdriver driver = new RemoteWebDriver(new URL(""), options);


I get this error: 

Oct 16, 2021 11:40:44 AM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '401' -> incorrect JSON status mapping for 'unknown error' (500 expected)

org.openqa.selenium.WebDriverException: failed serving request POST /wd/hub/session: Unauthorized
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-EB4CHGT', ip: '', 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.2'
Driver info: driver.version: RemoteWebDriver

0 replies

Be the first to reply!