use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class WebsiteTest method window_returnsWindowPlugin.
@Test
public void window_returnsWindowPlugin() {
RemoteWebDriver mockedWebDriver = mock(RemoteWebDriver.class);
Website website = Website.with(mockedWebDriver).visit(TEST_WEBSITE_URL);
WindowPlugin windowPlugin = website.window();
assertThat(windowPlugin).isNotNull();
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class JavaScriptPluginTest method executeAsync_callsExecuteAsyncScript.
@Test
public void executeAsync_callsExecuteAsyncScript() {
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
Object response = new Object();
when(mockedDriver.executeAsyncScript(anyString(), anyString())).thenReturn(response);
JavaScriptPlugin javaScriptPlugin = new JavaScriptPlugin(mockedDriver);
String script = "js script";
Object result = javaScriptPlugin.executeAsync(script, "paramOne");
verify(mockedDriver).executeAsyncScript(script, "paramOne");
assertThat(result).isSameAs(response);
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class ScreenshotPluginTest method takeAsBytes_executesConsumer.
@Test
public void takeAsBytes_executesConsumer() {
Consumer<byte[]> mockedConsumer = mock(Consumer.class);
byte[] screenshotBytes = new byte[0];
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
when(mockedDriver.getScreenshotAs(OutputType.BYTES)).thenReturn(screenshotBytes);
ScreenshotPlugin screenshotPlugin = new ScreenshotPlugin(mockedDriver);
screenshotPlugin.takeAsBytes(mockedConsumer);
verify(mockedConsumer).accept(screenshotBytes);
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class ScreenshotPluginTest method takeAnd_returnsScreenshotImage.
@Test
public void takeAnd_returnsScreenshotImage() throws Exception {
File file = mock(File.class);
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
when(mockedDriver.getScreenshotAs(OutputType.FILE)).thenReturn(file);
PowerMockito.mockStatic(ImageIO.class);
BufferedImage image = mock(BufferedImage.class);
PowerMockito.when(ImageIO.class, "read", file).thenReturn(image);
ScreenshotPlugin screenshotPlugin = new ScreenshotPlugin(mockedDriver);
ScreenshotImage screenshotImage = screenshotPlugin.takeAnd();
assertThat(screenshotImage).isEqualTo(new ScreenshotImage(image));
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class ScreenshotPluginTest method takeAnd_whenImageIOWriteThrowsIOException_throwsRuntimeException.
@Test
public void takeAnd_whenImageIOWriteThrowsIOException_throwsRuntimeException() throws Exception {
File file = mock(File.class);
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
when(mockedDriver.getScreenshotAs(OutputType.FILE)).thenReturn(file);
PowerMockito.mockStatic(ImageIO.class);
PowerMockito.doThrow(new IOException("Error")).when(ImageIO.class, "read", file);
expectedException.expect(RuntimeException.class);
expectedException.expectMessage("Error");
ScreenshotPlugin screenshotPlugin = new ScreenshotPlugin(mockedDriver);
screenshotPlugin.takeAnd();
}
Aggregations