SauceSession { public SauceSession start() throws MalformedURLException { capabilities = getCapabilities(); webDriver = remoteDriverManager.getRemoteWebDriver(sauceSeleniumServer, capabilities); sessionId = ((RemoteWebDriver) webDriver).getSessionId().toString(); test = new SauceApi(webDriver); api = new SauceREST(SAUCE_USERNAME, SAUCE_ACCESS_KEY); return this; } 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 public void startSession_invoked_setsNewSauceApiObject() throws MalformedURLException { RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class); sauceSession = new SauceSession(fakeRemoteDriver); sauceSession.start(); assertNotNull(sauceSession.test); }
@Test public void startSession_browserCapabilityKey_isCorrect() throws MalformedURLException { RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class); sauceSession = new SauceSession(fakeRemoteDriver); sauceSession.start(); String expectedBrowserCapabilityKey = "browserName"; String actualBrowser = sauceSession.capabilities.getCapability(expectedBrowserCapabilityKey).toString(); assertThat(actualBrowser, CoreMatchers.not(isEmptyOrNullString())); }
@Test public void setCapability_platformName_returnsCorrectOs() throws MalformedURLException { RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class); sauceSession = new SauceSession(fakeRemoteDriver); sauceSession.start(); String correctPlatformKey = "platformName"; String actualBrowser = sauceSession.capabilities.getCapability(correctPlatformKey).toString(); assertThat(actualBrowser, IsEqualIgnoringCase.equalToIgnoringCase("Windows 10")); }
@Test public void setCapability_browserVersion_returnsCorrectVersion() throws MalformedURLException { RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class); sauceSession = new SauceSession(fakeRemoteDriver); sauceSession.start(); String correctKey = "browserVersion"; String actualBrowser = sauceSession.capabilities.getCapability(correctKey).toString(); assertThat(actualBrowser, IsEqualIgnoringCase.equalToIgnoringCase("latest")); }