use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class ScreenshotPluginTest method takeAsFile_executesConsumer.
@Test
public void takeAsFile_executesConsumer() {
Consumer<File> mockedConsumer = mock(Consumer.class);
File file = mock(File.class);
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
when(mockedDriver.getScreenshotAs(OutputType.FILE)).thenReturn(file);
ScreenshotPlugin screenshotPlugin = new ScreenshotPlugin(mockedDriver);
screenshotPlugin.takeAsFile(mockedConsumer);
verify(mockedConsumer).accept(file);
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class ScreenshotPluginTest method take_savesFileToScreenshotDirectory.
@Test
public void take_savesFileToScreenshotDirectory() throws IOException {
File file = File.createTempFile("temporary", ".png");
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
when(mockedDriver.getScreenshotAs(OutputType.FILE)).thenReturn(file);
ScreenshotPlugin screenshotPlugin = new ScreenshotPlugin(mockedDriver);
screenshotPlugin.take();
File folder = new File("screenshot");
assertThat(folder.exists()).isTrue();
assertThat(folder.isDirectory()).isTrue();
assertThat(folder.listFiles()).hasSize(1);
FileUtils.forceDeleteOnExit(folder);
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class ScreenshotPluginTest method take_whenCopyThrowsIOException_throwsRuntimeException.
@Test
public void take_whenCopyThrowsIOException_throwsRuntimeException() throws IOException {
File file = mock(File.class);
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
when(mockedDriver.getScreenshotAs(OutputType.FILE)).thenReturn(file);
expectedException.expect(RuntimeException.class);
expectedException.expectMessage("Cannot save screenshot file");
ScreenshotPlugin screenshotPlugin = new ScreenshotPlugin(mockedDriver);
try {
screenshotPlugin.take();
} finally {
File folder = new File("screenshot");
FileUtils.forceDeleteOnExit(folder);
}
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class PagePluginTest method isLoad_whenPageIsLoad_returnsTrue.
@Test
public void isLoad_whenPageIsLoad_returnsTrue() {
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
when(mockedDriver.executeScript(anyString())).thenReturn("complete");
PagePlugin pagePlugin = new PagePlugin(mockedDriver);
boolean load = pagePlugin.isLoad();
verify(mockedDriver).executeScript("return document.readyState");
assertThat(load).isTrue();
}
use of org.openqa.selenium.remote.RemoteWebDriver in project flue2ent by DefinityLabs.
the class ScrollPluginTest method bottom_executesJavascript.
@Test
public void bottom_executesJavascript() {
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
ScrollPlugin scrollPlugin = new ScrollPlugin(mockedDriver);
ScrollPlugin result = scrollPlugin.bottom();
verify(mockedDriver).executeScript("window.scrollTo(0, document.body.scrollHeight);");
assertThat(result).isSameAs(scrollPlugin);
}
Aggregations