use of com.wikia.webdriver.common.core.imageutilities.Shooter in project selenium-tests by Wikia.
the class PageObjectLogging method log.
public static void log(String command, String description, boolean success, WebDriver driver) {
logsResults.add(success);
imageCounter += 1;
new Shooter().savePageScreenshot(screenPath + imageCounter, driver);
CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", getPageSource(driver));
String className = success ? "success" : "error";
StringBuilder builder = new StringBuilder();
builder.append("<tr class=\"" + className + "\"><td>" + command + "</td><td>" + description + "</td><td> <br/><a href='screenshots/screenshot" + imageCounter + ".png'>Screenshot</a><br/><a href='screenshots/screenshot" + imageCounter + ".html'>HTML Source</a></td></tr>");
CommonUtils.appendTextToFile(logPath, builder.toString());
logJSError(driver);
}
use of com.wikia.webdriver.common.core.imageutilities.Shooter in project selenium-tests by Wikia.
the class PageObjectLogging method onTestFailure.
@Override
public void onTestFailure(ITestResult result) {
driver = DriverProvider.getActiveDriver();
imageCounter += 1;
if ("true".equals(Configuration.getLogEnabled())) {
try {
new Shooter().savePageScreenshot(screenPath + imageCounter, driver);
CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", getPageSource(driver));
} catch (Exception e) {
log("onException", "driver has no ability to catch screenshot or html source - driver may died", false);
}
String exception = escapeHtml(result.getThrowable().toString() + "\n" + ExceptionUtils.getStackTrace(result.getThrowable()));
StringBuilder builder = new StringBuilder();
builder.append("<tr class=\"error\"><td>error</td><td><pre>" + exception + "</pre></td><td> <br/><a href='screenshots/screenshot" + imageCounter + ".png'>Screenshot</a><br/><a href='screenshots/screenshot" + imageCounter + ".html'>HTML Source</a></td></tr>");
CommonUtils.appendTextToFile(logPath, builder.toString());
logJSError(driver);
stopLogging();
}
}
use of com.wikia.webdriver.common.core.imageutilities.Shooter in project selenium-tests by Wikia.
the class PageObjectLogging method log.
public static void log(String command, Throwable e, boolean success, WebDriver driver) {
logsResults.add(success);
imageCounter += 1;
new Shooter().savePageScreenshot(screenPath + imageCounter, driver);
CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", getPageSource(driver));
String className = success ? "success" : "error";
StringBuilder builder = new StringBuilder();
builder.append("<tr class=\"" + className + "\"><td>" + command + "</td><td>" + e.getMessage() + "</td><td> <br/><a href='screenshots/screenshot" + imageCounter + ".png'>Screenshot</a><br/><a href='screenshots/screenshot" + imageCounter + ".html'>HTML Source</a></td></tr>");
CommonUtils.appendTextToFile(logPath, builder.toString());
logJSError(driver);
}
use of com.wikia.webdriver.common.core.imageutilities.Shooter in project selenium-tests by Wikia.
the class AdsSkinHelper method init.
private void init() {
this.adsComparison = new AdsComparison();
this.imageEditor = new ImageEditor();
this.shooter = new Shooter();
this.imageComparison = new ImageComparison();
WebElement wikiaArticle = driver.findElement(By.id("WikiaPageBackground"));
WebElement globalNavigation = driver.findElement(By.id("globalNavigation"));
this.viewPortWidth = globalNavigation.getSize().getWidth();
this.startSkinY = globalNavigation.getSize().getHeight();
this.articleLeftSideX = wikiaArticle.getLocation().x;
this.articleBottomY = wikiaArticle.getLocation().y + wikiaArticle.getSize().getHeight();
this.articleRightSideX = wikiaArticle.getLocation().x + wikiaArticle.getSize().getWidth();
}
use of com.wikia.webdriver.common.core.imageutilities.Shooter in project selenium-tests by Wikia.
the class CommonExpectedConditions method elementToHaveColor.
/**
* @param accuracy in percentage between 0 and 100.
*/
public static ExpectedCondition<Boolean> elementToHaveColor(final WebElement element, final Color color, final int accuracy) {
final Shooter shooter = new Shooter();
final ImageComparison imageComparison = new ImageComparison();
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
BufferedImage image = shooter.takeScreenshot(element, driver);
return imageComparison.isColorImage(image, color, accuracy);
}
@Override
public String toString() {
return String.format("At least %s percents of element does not have %s color", (100 - accuracy), color.toString());
}
};
}
Aggregations