SauceSession { public MutableCapabilities getCapabilities() { sauceOptions = getSauceOptions(); setBrowserOptions(browserName); capabilities.setCapability(sauceOptionsTag, sauceOptions); capabilities.setCapability(CapabilityType.BROWSER_NAME, browserName); capabilities.setCapability(CapabilityType.PLATFORM_NAME, operatingSystem); capabilities.setCapability(CapabilityType.BROWSER_VERSION, browserVersion); return capabilities; } SauceSession();  SauceSession(RemoteDriverInterface remoteManager); SauceSession start(); MutableCapabilities getCapabilities(); MutableCapabilities getSauceOptions(); void setBrowserOptions(String browserName); SauceSession withChrome(); SauceSession withFirefox(); RemoteDriverInterface getDriverManager(); MutableCapabilities getSauceOptionsCapability(); WebDriver getDriver(); SauceSession withMacOsMojave(); SauceSession withMacOsHighSierra(); SauceSession withBrowserVersion(String browserVersion); SauceSession withEdge(); SauceSession withIE(); SauceSession withPlatform(String operatingSystem); SauceSession withBrowser(String browserName, String browserVersion); SauceSession withBrowser(String browserName); SauceSession withTestName(String testName); SauceSession withBuildName(String buildName); void stop(); void passed(); void failed(); void setTestName(String testName); void setBuildTag(String buildTag); void setBuild(String build); public SauceApi test; public MutableCapabilities capabilities; }
@Test @Ignore("The problem with this approach is that you need to know which method" + "to call to get the desired behavior. However, if we move the logic out from" + "the getCapabilities() method into another method, this test will no longer work." + "So this test is implementation specific. The test above is not.") public void getCapabilities_browserNameCapSet_validKeyExists2() { sauceSession.getCapabilities(); String expectedBrowserCapabilityKey = "browserName"; String actualBrowser = sauceSession.capabilities.getCapability(expectedBrowserCapabilityKey).toString(); assertThat(actualBrowser, IsNot.not("")); }
@Test public void noSauceOptionsSet_whenCreated_defaultIsChrome() { String actualBrowser = sauceSession.getCapabilities().getBrowserName(); assertThat(actualBrowser, IsEqualIgnoringCase.equalToIgnoringCase("Chrome")); }
@Test public void noSauceOptionsSet_whenCreated_defaultIsWindows10() { String actualOs = sauceSession.getCapabilities().getPlatform().name(); assertThat(actualOs, IsEqualIgnoringCase.equalToIgnoringCase("win10")); }
@Test public void noSauceOptionsSet_whenCreated_latestBrowserVersion() { MutableCapabilities caps = new SauceSession().getCapabilities(); String actualOperatingSystem = caps.getCapability("browserVersion").toString(); assertThat(actualOperatingSystem, IsEqualIgnoringCase.equalToIgnoringCase("latest")); }