Search in sources :

Example 91 with RemoteWebDriver

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

Example 92 with RemoteWebDriver

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

Example 93 with RemoteWebDriver

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

Example 94 with RemoteWebDriver

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));
}
Also used : ScreenshotImage(org.definitylabs.flue2ent.plugin.screenshot.ScreenshotImage) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) ImageIO(javax.imageio.ImageIO) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 95 with RemoteWebDriver

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

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