Examples of TakesScreenshot


Examples of org.openqa.selenium.TakesScreenshot

    if (driver instanceof EventFiringWebDriver) {
      EventFiringWebDriver eventFiringWebDriver = (EventFiringWebDriver) driver;
      driver = eventFiringWebDriver.getWrappedDriver();
    }
    if (driver instanceof TakesScreenshot) {
      TakesScreenshot takesScreenshotWebDriver = (TakesScreenshot) driver;
      File srcFile = takesScreenshotWebDriver.getScreenshotAs(OutputType.FILE);
      log(element, log, srcFile);
      removeStyleafterSnapShot(element, driver);
    } else {
      log(element, log, null);
    }
View Full Code Here

Examples of org.openqa.selenium.TakesScreenshot

      Echo.echo("capture html failed: " + e);
    }

    // Try to capture a screenshot
    if (driver instanceof TakesScreenshot) {
      TakesScreenshot ss = (TakesScreenshot) driver;
      try {
        byte[] bytes = ss.getScreenshotAs(OutputType.BYTES);
        saveToFile(dir + name + ".capture.png", bytes);
      } catch (WebDriverException e) {
        Echo.echo("capture screenshot failed: " + e);
      }
    }
View Full Code Here

Examples of org.openqa.selenium.TakesScreenshot

  @Test
  public void screenshot() throws Exception {
    File to = new File("ss.png");
    to.delete();
    Assert.assertFalse(to.exists());
    TakesScreenshot d = (TakesScreenshot) (IOSDriverAugmenter.augment(driver));
    to = d.getScreenshotAs(OutputType.FILE);
    Assert.assertTrue(to.exists());
  }
View Full Code Here

Examples of org.openqa.selenium.TakesScreenshot

        return path;
    }

    @Override
    public String takeScreenshot(String filename) throws WebDriverException, UnsupportedOperationException {
        TakesScreenshot tss = getTakesScreenshot();
        if (tss == null)
            throw new UnsupportedOperationException("webdriver does not support capturing screenshot.");
        File file = new File(PathUtils.normalize(filename));
        if (screenshotDir != null)
            file = new File(screenshotDir, file.getName());
View Full Code Here

Examples of org.openqa.selenium.TakesScreenshot

    @Override
    public String takeScreenshotAll(String prefix, int index) {
        if (screenshotAllDir == null)
            return null;
        TakesScreenshot tss = getTakesScreenshot();
        if (tss == null)
            return null;
        String filename = String.format("%s_%s_%d.png", prefix, FILE_DATE_TIME.format(Calendar.getInstance()), index);
        try {
            File file = new File(screenshotAllDir, filename);
View Full Code Here

Examples of org.openqa.selenium.TakesScreenshot

    @Override
    public String takeScreenshotOnFail(String prefix, int index) {
        if (screenshotOnFailDir == null)
            return null;
        TakesScreenshot tss = getTakesScreenshot();
        if (tss == null)
            return null;
        String filename = String.format("%s_%s_%d_fail.png", prefix, FILE_DATE_TIME.format(Calendar.getInstance()), index);
        try {
            File file = new File(screenshotOnFailDir, filename);
View Full Code Here

Examples of org.openqa.selenium.TakesScreenshot

public class ScreenShotOnErrorTest {

    @Test
    public void canTakeScreenShotAndMoveIt() throws IOException {

        TakesScreenshot ts = mock(TakesScreenshot.class);
        File file = new File(".foo");
        file.createNewFile();
        file.deleteOnExit();
        when(ts.getScreenshotAs(OutputType.FILE)).thenReturn(file);

        ScreenShotOnError ssoe = new ScreenShotOnError(ts, ScreenShotOnErrorTest.class, "target/test-classes/", "target/");
        ssoe.setContext("baz");
        FluentExecutionStopped boo = new FluentExecutionStopped("boo", null);
        FluentExecutionStopped bar = ssoe.exceptionDuringExecution(boo, null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.