Search in sources :

Example 11 with Augmenter

use of org.openqa.selenium.remote.Augmenter in project selenium_java by sergueik.

the class AppiumTest method test.

@Test
public void test() throws Exception {
    driver.get("https://www.carnival.com");
    driver = new Augmenter().augment(driver);
    File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    try {
        FileUtils.copyFile(srcFile, new File("Screenshot.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Augmenter(org.openqa.selenium.remote.Augmenter) IOException(java.io.IOException) File(java.io.File) TakesScreenshot(org.openqa.selenium.TakesScreenshot) Test(org.testng.annotations.Test)

Example 12 with Augmenter

use of org.openqa.selenium.remote.Augmenter in project selenium_java by sergueik.

the class AppTest method testSimple.

@Test
public void testSimple() throws Exception {
    driver.get("http://www.google.com");
    String title = driver.getTitle();
    System.out.println("Page title is: " + title);
    WebElement element = driver.findElement(By.name("q"));
    element.sendKeys("TestingBot");
    element.submit();
    driver = new Augmenter().augment(driver);
    File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    try {
        FileUtils.copyFile(srcFile, new File("Screenshot.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Augmenter(org.openqa.selenium.remote.Augmenter) IOException(java.io.IOException) WebElement(org.openqa.selenium.WebElement) File(java.io.File) TakesScreenshot(org.openqa.selenium.TakesScreenshot) Test(org.junit.Test) ParallelTest(com.mycompany.app.ParallelTest)

Example 13 with Augmenter

use of org.openqa.selenium.remote.Augmenter in project selenium_java by sergueik.

the class App method testSimple.

@Test
public void testSimple() throws Exception {
    driver.get("http://www.google.com");
    String title = driver.getTitle();
    System.out.println("Page title is: " + title);
    WebElement element = driver.findElement(By.name("q"));
    element.sendKeys("TestingBot");
    element.submit();
    driver = new Augmenter().augment(driver);
    File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    try {
        FileUtils.copyFile(srcFile, new File("Screenshot.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Augmenter(org.openqa.selenium.remote.Augmenter) IOException(java.io.IOException) WebElement(org.openqa.selenium.WebElement) File(java.io.File) TakesScreenshot(org.openqa.selenium.TakesScreenshot) Test(org.junit.Test) ParallelTest(com.mycompany.app.ParallelTest)

Example 14 with Augmenter

use of org.openqa.selenium.remote.Augmenter in project java.webdriver by sayems.

the class ScreenshotListener method onTestFailure.

@Override
public void onTestFailure(ITestResult failingTest) {
    try {
        WebDriver driver = driver();
        String screenshotDirectory = System.getProperty("screenshotDirectory", "target/screenshots");
        String screenshotAbsolutePath = screenshotDirectory + File.separator + System.currentTimeMillis() + "_" + failingTest.getName() + ".png";
        File screenshot = new File(screenshotAbsolutePath);
        if (createFile(screenshot)) {
            try {
                writeScreenshotToFile(driver, screenshot);
            } catch (ClassCastException weNeedToAugmentOurDriverObject) {
                writeScreenshotToFile(new Augmenter().augment(driver), screenshot);
            }
            System.out.println("Written screenshot to " + screenshotAbsolutePath);
        } else {
            System.err.println("Unable to create " + screenshotAbsolutePath);
        }
    } catch (Exception ex) {
        System.err.println("Unable to capture screenshot...");
        ex.printStackTrace();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Augmenter(org.openqa.selenium.remote.Augmenter) File(java.io.File) IOException(java.io.IOException)

Aggregations

Augmenter (org.openqa.selenium.remote.Augmenter)14 File (java.io.File)13 IOException (java.io.IOException)11 TakesScreenshot (org.openqa.selenium.TakesScreenshot)11 WebDriver (org.openqa.selenium.WebDriver)5 WebDriverException (org.openqa.selenium.WebDriverException)3 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)3 Test (org.testng.annotations.Test)3 ParallelTest (com.mycompany.app.ParallelTest)2 BufferedImage (java.awt.image.BufferedImage)2 Test (org.junit.Test)2 WebElement (org.openqa.selenium.WebElement)2 OutputFile (com.coveros.selenified.OutputFile)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 JenkinsServer (com.offbytwo.jenkins.JenkinsServer)1 ActivityPageFactory (io.blueocean.ath.factory.ActivityPageFactory)1 BranchPageFactory (io.blueocean.ath.factory.BranchPageFactory)1 ClassicPipelineFactory (io.blueocean.ath.factory.ClassicPipelineFactory)1 FreestyleJobFactory (io.blueocean.ath.factory.FreestyleJobFactory)1 MultiBranchPipelineFactory (io.blueocean.ath.factory.MultiBranchPipelineFactory)1