use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method noContainerIsStartedWhenCapabilitiesAreNotSupported.
@Test
public void noContainerIsStartedWhenCapabilitiesAreNotSupported() {
// Non supported desired capability for the test session
Map<String, Object> nonSupportedCapability = new HashMap<>();
nonSupportedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.SAFARI);
nonSupportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.MAC);
TestSession testSession = spyProxy.getNewSession(nonSupportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, never()).startDockerSeleniumContainer(timeZone, screenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method noContainerIsStartedForAlreadyProcessedRequest.
@Test
public void noContainerIsStartedForAlreadyProcessedRequest() {
Map<String, Object> requestedCapability = new HashMap<>();
requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.LINUX);
ProcessedCapabilities processedCapabilities = new ProcessedCapabilities(requestedCapability, System.identityHashCode(requestedCapability));
DockerSeleniumStarterRemoteProxy.processedCapabilitiesList.add(processedCapabilities);
TestSession testSession = spyProxy.getNewSession(requestedCapability);
Assert.assertNull(testSession);
verify(spyProxy, times(0)).startDockerSeleniumContainer(timeZone, screenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method noContainerIsStartedWhenPlatformIsNotSupported.
@Test
public void noContainerIsStartedWhenPlatformIsNotSupported() {
// Non supported desired capability for the test session
Map<String, Object> nonSupportedCapability = new HashMap<>();
nonSupportedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
nonSupportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.WINDOWS);
TestSession testSession = spyProxy.getNewSession(nonSupportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, never()).startDockerSeleniumContainer(timeZone, screenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method containerIsStartedWhenResolutionIsProvided.
@Test
public void containerIsStartedWhenResolutionIsProvided() {
// Supported desired capability for the test session
Dimension customScreenSize = new Dimension(1300, 900);
Map<String, Object> supportedCapability = new HashMap<>();
supportedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
supportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.ANY);
String screenResolution = String.format("%sx%s", customScreenSize.getWidth(), customScreenSize.getHeight());
supportedCapability.put("resolution", screenResolution);
TestSession testSession = spyProxy.getNewSession(supportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, timeout(1000).times(1)).startDockerSeleniumContainer(timeZone, customScreenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method testEventIsInvoked.
@Test
public void testEventIsInvoked() throws IOException {
try {
// 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);
Assert.assertNotNull(testSession);
// We release the sessions and invoke the afterCommand with a mocked object
Environment env = mock(Environment.class);
when(env.getBooleanEnvVariable("ZALENIUM_SEND_ANONYMOUS_USAGE_INFO", false)).thenReturn(true);
when(env.getStringEnvVariable("ZALENIUM_GA_API_VERSION", "")).thenReturn("1");
when(env.getStringEnvVariable("ZALENIUM_GA_TRACKING_ID", "")).thenReturn("UA-88441352");
when(env.getStringEnvVariable("ZALENIUM_GA_ENDPOINT", "")).thenReturn("https://www.google-analytics.com/collect");
when(env.getStringEnvVariable("ZALENIUM_GA_ANONYMOUS_CLIENT_ID", "")).thenReturn("RANDOM_STRING");
HttpClient client = mock(HttpClient.class);
HttpResponse httpResponse = mock(HttpResponse.class);
when(client.execute(any(HttpPost.class))).thenReturn(httpResponse);
GoogleAnalyticsApi ga = new GoogleAnalyticsApi();
GoogleAnalyticsApi gaSpy = spy(ga);
gaSpy.setEnv(env);
gaSpy.setHttpClient(client);
SauceLabsRemoteProxy.setGa(gaSpy);
WebDriverRequest webDriverRequest = mock(WebDriverRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(webDriverRequest.getMethod()).thenReturn("DELETE");
when(webDriverRequest.getRequestType()).thenReturn(RequestType.STOP_SESSION);
testSession.getSlot().doFinishRelease();
testSession.setExternalKey(new ExternalSessionKey("testKey"));
sauceLabsProxy.afterCommand(testSession, webDriverRequest, response);
verify(gaSpy, times(1)).testEvent(anyString(), anyString(), anyLong());
} finally {
SauceLabsRemoteProxy.restoreGa();
}
}
Aggregations