use of org.openqa.selenium.remote.Augmenter in project mamute by caelum.
the class FailFastListener method takeScreenshot.
private void takeScreenshot(File tempDir) throws IOException {
try {
driver = new Augmenter().augment(driver);
File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
File png = new File(tempDir, "failure" + System.currentTimeMillis() + ".png");
FileUtils.copyFile(srcFile, png);
System.err.println("screenshot saved to " + png.getAbsolutePath());
} catch (Exception e) {
System.err.println("could not save screen shot, see exception below");
e.printStackTrace();
}
}
use of org.openqa.selenium.remote.Augmenter in project selenium_java by sergueik.
the class AppTest method test.
@Test
public void test() throws Exception {
driver.get("http://www.amazon.com/");
System.out.println("Page title is: " + driver.getTitle());
assertEquals("Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more", driver.getTitle());
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();
}
}
use of org.openqa.selenium.remote.Augmenter in project selenium_java by sergueik.
the class BrowserTest method test.
@Test
public void test() throws Exception {
driver.get("http://www.amazon.com/");
System.out.println("Page title is: " + driver.getTitle());
assertEquals("Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more", driver.getTitle());
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();
}
}
use of org.openqa.selenium.remote.Augmenter in project selenium_java by sergueik.
the class BaseTest method tearDown.
@AfterMethod
public void tearDown(ITestResult result, ITestContext context) throws Exception {
Throwable t = result.getThrowable();
if (t instanceof WebDriverException || t instanceof AssertionError) {
// System.out.println("WebDriver or Assert Exception");
// get filename
Calendar cal = Calendar.getInstance();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
// concat prefix with current time and return
String filename = result.getTestClass().getName() + "." + result.getMethod().getMethodName() + "." + sf.format(cal.getTime()) + ".png";
WebDriver augmentedDriver = new Augmenter().augment(driver);
File scrFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(context.getOutputDirectory() + separator + filename));
Reporter.setCurrentTestResult(result);
Reporter.log("<a href=\"" + filename + "\">Screenshot</a>");
}
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
Assert.fail(verificationErrorString);
}
}
use of org.openqa.selenium.remote.Augmenter in project ashot by yandex-qatools.
the class SimpleShootingStrategy method getScreenshot.
@Override
public BufferedImage getScreenshot(WebDriver wd) {
ByteArrayInputStream imageArrayStream = null;
TakesScreenshot takesScreenshot;
try {
takesScreenshot = (TakesScreenshot) wd;
} catch (ClassCastException ignored) {
takesScreenshot = (TakesScreenshot) new Augmenter().augment(wd);
}
try {
imageArrayStream = new ByteArrayInputStream(takesScreenshot.getScreenshotAs(OutputType.BYTES));
return ImageIO.read(imageArrayStream);
} catch (IOException e) {
throw new ImageReadException("Can not parse screenshot data", e);
} finally {
IOUtils.closeQuietly(imageArrayStream);
}
}
Aggregations