Search in sources :

Example 41 with RemoteWebDriver

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);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) File(java.io.File) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 42 with RemoteWebDriver

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);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) File(java.io.File) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 43 with RemoteWebDriver

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);
    }
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) File(java.io.File) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 44 with RemoteWebDriver

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();
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Test(org.junit.Test)

Example 45 with RemoteWebDriver

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);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Test(org.junit.Test)

Aggregations

RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)101 URL (java.net.URL)39 Test (org.junit.Test)36 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)29 File (java.io.File)16 WebDriver (org.openqa.selenium.WebDriver)14 MalformedURLException (java.net.MalformedURLException)13 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)13 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)12 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)12 IOException (java.io.IOException)11 Dimension (org.openqa.selenium.Dimension)9 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)7 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)6 EventFiringWebDriver (org.openqa.selenium.support.events.EventFiringWebDriver)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Before (org.junit.Before)5