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
@BeforeClass
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");
options.setCapability("browserName","chrome");
Webdriver driver = new RemoteWebDriver(new URL("https://ondemand.us-west-1.saucelabs.com:443/wd/hub"), options);
}
CodePudding user response:
This is working for me,
DesiredCapabilities DC = DesiredCapabilities.chrome();
DC.setBrowserName("chrome");
DC.setPlatform(Platform.WIN10);
driver = new RemoteWebDriver(new URL("https://oauth-jayanth_balakrishnan-ae.saucelabs.com:443/wd/hub"), DC); //http://127.0.0.1:4444/wd/hub
CodePudding user response:
import com.saucelabs.saucebindings.testng.SauceBaseTest;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Example Test for running with the TestNG Sauce Bindings library.
*/
public class SauceBindingsTestngTest extends SauceBaseTest {
@Test
public void correctTitle() {
getDriver().navigate().to("https://www.saucedemo.com");
Assert.assertEquals("Swag Labs", getDriver().getTitle());
}
}
Chrome/Win10 is the default so no setup code is required. If you want to change the configuration, check the Sauce Bindings docs below.
We have a Demo Java repo with any example you want, just browse the table of contents
We use Sauce Bindings to make the code so simple