use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method doesNotCreateSessionWhenDockerSeleniumCanProcessRequest.
@Test
public void doesNotCreateSessionWhenDockerSeleniumCanProcessRequest() {
// This capability is supported by docker-selenium, so it should return a null session
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.LINUX);
TestSession testSession = sauceLabsProxy.getNewSession(requestedCapability);
Assert.assertNull(testSession);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method checkBeforeSessionInvocation.
@Test
public void checkBeforeSessionInvocation() throws IOException {
// Capability which should result in a created session
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.SAFARI);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.MAC);
// Getting a test session in the sauce labs node
TestSession testSession = sauceLabsProxy.getNewSession(requestedCapability);
System.out.println(requestedCapability.toString());
Assert.assertNotNull(testSession);
// We need to mock all the needed objects to forward the session and see how in the beforeMethod
// the SauceLabs user and api key get added to the body request.
WebDriverRequest request = TestUtils.getMockedWebDriverRequestStartSession(BrowserType.SAFARI, Platform.MAC);
HttpServletResponse response = mock(HttpServletResponse.class);
ServletOutputStream stream = mock(ServletOutputStream.class);
when(response.getOutputStream()).thenReturn(stream);
testSession.forward(request, response, true);
Environment env = new Environment();
// The body should now have the SauceLabs variables
String expectedBody = String.format("{\"desiredCapabilities\":{\"browserName\":\"safari\",\"platformName\":" + "\"MAC\",\"username\":\"%s\",\"accessKey\":\"%s\",\"version\":\"latest\"}}", env.getStringEnvVariable("SAUCE_USERNAME", ""), env.getStringEnvVariable("SAUCE_ACCESS_KEY", ""));
verify(request).setBody(expectedBody);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method sessionIsCreatedWithCapabilitiesThatDockerSeleniumCannotProcess.
@Test
public void sessionIsCreatedWithCapabilitiesThatDockerSeleniumCannotProcess() {
// Capability which should result in a created session
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.EDGE);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.WIN10);
TestSession testSession = sauceLabsProxy.getNewSession(requestedCapability);
Assert.assertNotNull(testSession);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class TestingBotRemoteProxyTest method credentialsAreAddedInSessionCreation.
@Test
public void credentialsAreAddedInSessionCreation() throws IOException {
// Capability which should result in a created session
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.IE);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.WIN8);
// Getting a test session in the TestingBot node
TestSession testSession = testingBotProxy.getNewSession(requestedCapability);
Assert.assertNotNull(testSession);
// We need to mock all the needed objects to forward the session and see how in the beforeMethod
// the TestingBot user and api key get added to the body request.
WebDriverRequest request = TestUtils.getMockedWebDriverRequestStartSession(BrowserType.IE, Platform.WIN8);
HttpServletResponse response = mock(HttpServletResponse.class);
ServletOutputStream stream = mock(ServletOutputStream.class);
when(response.getOutputStream()).thenReturn(stream);
testSession.forward(request, response, true);
Environment env = new Environment();
// The body should now have the TestingBot variables
String expectedBody = String.format("{\"desiredCapabilities\":{\"browserName\":\"internet explorer\",\"platformName\":" + "\"WIN8\",\"key\":\"%s\",\"secret\":\"%s\",\"version\":\"latest\"}}", env.getStringEnvVariable("TESTINGBOT_KEY", ""), env.getStringEnvVariable("TESTINGBOT_SECRET", ""));
verify(request).setBody(expectedBody);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class TestingBotRemoteProxyTest method sessionIsCreatedWithCapabilitiesThatDockerSeleniumCannotProcess.
@Test
public void sessionIsCreatedWithCapabilitiesThatDockerSeleniumCannotProcess() {
// Capability which should result in a created session
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.IE);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.WIN8);
TestSession testSession = testingBotProxy.getNewSession(requestedCapability);
Assert.assertNotNull(testSession);
}
Aggregations