Package net.mindengine.galen.page

Examples of net.mindengine.galen.page.PageElement


        }
    }

    @Override
    public void check(PageValidation pageValidation, String objectName, SpecImage spec) throws ValidationErrorException {
        PageElement pageElement = pageValidation.findPageElement(objectName);
        checkAvailability(pageElement, objectName);

        final BufferedImage pageImage = pageValidation.getPage().getScreenshotImage();

        // TODO fix. should only take screenshot once per the same page if there are multiple image comparison checks

        int tolerance = spec.getTolerance() != null ? Math.abs(spec.getTolerance()) : 25;

        ComparisonOptions options = new ComparisonOptions();
        options.setStretchToFit(spec.isStretch());
        options.setOriginalFilters(spec.getOriginalFilters());
        options.setSampleFilters(spec.getSampleFilters());
        options.setMapFilters(spec.getMapFilters());
        options.setTolerance(tolerance);


        Rect elementArea = pageElement.getArea();

        ImageCheck minCheck = new ImageCheck(spec.getImagePaths().get(0), elementArea.getHeight() * elementArea.getWidth() * 2, null, null);

        Iterator<String> it = spec.getImagePaths().iterator();

        if (!it.hasNext()) {
            throw new ValidationErrorException("There are now images defined to compare with")
                    .withErrorArea(new ErrorArea(pageElement.getArea(), objectName));
        }

        try {
            while (minCheck.difference > 0 && it.hasNext()) {
                String imagePath = it.next();

                ImageCheck imageCheck = checkImages(spec, pageImage, options, elementArea, imagePath);
                if (imageCheck.difference <= minCheck.difference) {
                    minCheck = imageCheck;
                }
            }
        }
        catch (ValidationErrorException ex) {
            ex.withErrorArea(new ErrorArea(pageElement.getArea(), objectName));
            throw ex;
        }
        catch (Exception ex) {
            throw new ValidationErrorException(ex).withErrorArea(new ErrorArea(pageElement.getArea(), objectName));
        }

        if (minCheck.difference > 0) {
            throw new ValidationErrorException(minCheck.errorMessage)
                    .withErrorArea(new ErrorArea(pageElement.getArea(), objectName))
                    .withImageComparison(new ImageComparison(spec.getSelectedArea(), minCheck.imagePath, minCheck.result.getComparisonMap()));
        }
    }
View Full Code Here


public abstract class SpecValidationAligned<T extends SpecAligned> extends SpecValidation<T> {

    @Override
    public void check(PageValidation pageValidation, String objectName, T spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
       
        checkAvailability(mainObject, objectName);
       
        PageElement childObject = pageValidation.findPageElement(spec.getObject());
        checkAvailability(childObject, spec.getObject());
       
        int offset = Math.abs(getOffset(spec, mainObject, childObject));
        if (offset > Math.abs(spec.getErrorRate())) {
            throw new ValidationErrorException(Arrays.asList(new ErrorArea(mainObject.getArea(), objectName), new ErrorArea(childObject.getArea(), spec.getObject())),
                    Arrays.asList(errorMisalignedObjects(objectName, spec.getObject(), spec, offset)));
        }
    }
View Full Code Here

public class SpecValidationComponent extends SpecValidation<SpecComponent> {

    @Override
    public void check(PageValidation pageValidation, String objectName, SpecComponent spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
        checkAvailability(mainObject, objectName);

        Page page = pageValidation.getPage();
        Locator mainObjectLocator = pageValidation.getPageSpec().getObjectLocator(objectName);
        Page objectContextPage = page.createObjectContextPage(mainObjectLocator);
View Full Code Here

public class SpecValidationCentered extends SpecValidation<SpecCentered> {

    @Override
    public void check(PageValidation pageValidation, String objectName, SpecCentered spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
        checkAvailability(mainObject, objectName);
       
        PageElement secondObject = pageValidation.findPageElement(spec.getObject());
        checkAvailability(secondObject, spec.getObject());
       
        Rect mainArea = mainObject.getArea();
        Rect secondArea = secondObject.getArea();
       
        int offsetLeft = mainArea.getLeft() - secondArea.getLeft();
        int offsetRight = secondArea.getLeft() + secondArea.getWidth() - mainArea.getLeft() - mainArea.getWidth();
       
        int offsetTop = mainArea.getTop() - secondArea.getTop();
View Full Code Here

public class SpecValidationText<T extends SpecText> extends SpecValidation<T> {

    @Override
    public void check(PageValidation pageValidation, String objectName, T spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
       
        checkAvailability(mainObject, objectName);
       
        Rect area = mainObject.getArea();
        String realText = mainObject.getText();
        if (realText == null) {
            realText = "";
        }

        realText = applyOperationsTo(realText, spec.getOperations());
View Full Code Here

        }
    }
   

    private PageElement getWebPageElement(String objectName, Locator objectLocator) {
        PageElement pageElement = cachedPageElements.get(objectName);
       
        if (pageElement == null) {
            pageElement = locatorToElement(objectName, objectLocator);
           
            cachedPageElements.put(objectName, pageElement);
View Full Code Here

            return pageElement;
        }
    }

    private PageElement locatorToElement(String objectName, Locator objectLocator) {
        PageElement pageElement;
        By by = by(objectLocator);
        if (by == null) {
            return null;
        }
       
View Full Code Here

        if (index > 0 && index < valuePath.length() - 1) {
            String objectName = valuePath.substring(0, index);
            String fieldPath = valuePath.substring(index + 1);
           
            Locator locator = pageSpec.getObjectLocator(objectName);
            PageElement pageElement = findPageElementOnPage(objectName, locator);
           
            if (pageElement != null) {
                Object objectValue = getObjectValue(pageElement, fieldPath);
                int value = convertToInt(objectValue);
               
View Full Code Here

       
        boolean state = true;
       
        for (Until until : untilElements) {
           
            PageElement element = page.getObject(until.getLocator());
           
            if (!checkElement(element, until)) {
                state = false;
                if (result != null) {
                    result.append(" - " + until.getType().toString() + " " + until.getLocator().prettyString() + "\n");
View Full Code Here

    public JsPageElement find(String objectName) {
        if (browser != null && pageSpec.getObjects().containsKey(objectName)) {
            Page page = browser.getPage();
            Locator locator = pageSpec.getObjectLocator(objectName);
            if (locator != null) {
                PageElement pageElement = page.getObject(objectName, locator);
                if (pageElement != null) {
                    return new JsPageElement(pageElement);
                }
            }
        }
View Full Code Here

TOP

Related Classes of net.mindengine.galen.page.PageElement

Copyright © 2018 www.massapicom. 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.