Package net.mindengine.galen.specs.page

Examples of net.mindengine.galen.specs.page.Locator


   
    @Test(dependsOnMethods = BASE_TEST)
    public void shouldRead_objectDefinitions() {
        Map<String, Locator> objects = pageSpec.getObjects();
        assertThat("Amount of objects should be", objects.size(), is(5));
        assertThat(objects, hasEntry("submit", new Locator("xpath", "//input[@name = 'submit']")));
        assertThat(objects, hasEntry("search-field", new Locator("css", "#search")));
        assertThat(objects, hasEntry("menu", new Locator("id", "menu")));
        assertThat(objects, hasEntry("big-box", new Locator("tag", "container")));
        assertThat(objects, hasEntry("anotherObject", new Locator("xpath", "//div")));
       
        assertThat("Amount of multi-objects should be", pageSpec.getMultiObjects().size(), is(1));
        assertThat(pageSpec.getMultiObjects(), hasEntry("menu-item-*", new Locator("css", "#menu .menu-item")));
    }
View Full Code Here


    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);
       
        ValidationListener validationListener = pageValidation.getValidationListener();

        PageSpecReader pageSpecReader = new PageSpecReader(spec.getProperties(), pageValidation.getBrowser());
View Full Code Here

            List<WebElement> webElements = driverFindElements(by);
           
            pageElements = new LinkedList<PageElement>();
            int i = 1;
            for (WebElement webElement : webElements) {
                pageElements.add(new WebPageElement(objectName, webElement, new Locator(objectLocator.getLocatorType(), objectLocator.getLocatorValue(), i)));
                i++;
            }
        }
        if (index < pageElements.size()) {
             return pageElements.get(index);
View Full Code Here

    }
   
    @DataProvider
    public Object[][] provideGoodSamples() {
        return new Object[][]{
            row("myObject id my-object", "myObject", new Locator("id", "my-object")),
            row("myObject\tid\tmy-object", "myObject", new Locator("id", "my-object")),
            row("myObject xpath   //div[@name = \"auto's\"]", "myObject", new Locator("xpath", "//div[@name = \"auto's\"]")),
            row("myObject whatEver   sas fas f 3r 32r 1qwr ", "myObject", new Locator("whatEver", "sas fas f 3r 32r 1qwr")),
            row("my-object-123    css   .container div:first-child()", "my-object-123", new Locator("css", ".container div:first-child()")),
            row("my-object-123    css   #qwe", "my-object-123", new Locator("css", "#qwe")),
            row("my-object-123  @(0,0,-1,-1)  css   #qwe", "my-object-123", new Locator("css", "#qwe").withCorrections(simpleCorrectionRect(0, 0, -1, -1))),
            row("my-object-123  @  (0,0,-1,-1)  css   #qwe", "my-object-123", new Locator("css", "#qwe").withCorrections(simpleCorrectionRect(0, 0, -1, -1))),
            row("my-object-123  @(10, 20, +5, +30)  css   #qwe", "my-object-123", new Locator("css", "#qwe").withCorrections(simpleCorrectionRect(10, 20, 5, 30))),
            row("my-object-123  @ ( 0 , 0 , 4, -5 )  css   #qwe", "my-object-123", new Locator("css", "#qwe").withCorrections(simpleCorrectionRect(0, 0, 4, -5))),
            row("my-object-123  @ ( 0 , 0 , =40, =30 )  css   #qwe", "my-object-123",
                    new Locator("css", "#qwe").withCorrections(
                            new CorrectionsRect(new CorrectionsRect.Correction(0, CorrectionsRect.Type.PLUS),
                                    new CorrectionsRect.Correction(0, CorrectionsRect.Type.PLUS),
                                    new CorrectionsRect.Correction(40, CorrectionsRect.Type.EQUALS),
                                    new CorrectionsRect.Correction(30, CorrectionsRect.Type.EQUALS)))),
        };
View Full Code Here

    public void setPageSpec(PageSpec pageSpec) {
        this.pageSpec = pageSpec;
    }

    public PageElement findPageElement(String objectName) {
        Locator objectLocator = pageSpec.getObjectLocator(objectName);
        if (objectLocator != null) {
            return page.getObject(objectName, objectLocator);
        }
        else {
            return page.getSpecialObject(objectName);
View Full Code Here

        int index = valuePath.indexOf("/");
        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

       
        int count = page.getObjectCount(objectLocator);
       
        for (int index = 1; index <= count; index++) {
            String singleObjectName = objectName.replace("*", Integer.toString(index));
            Locator newLocator = new Locator(objectLocator.getLocatorType(), objectLocator.getLocatorValue(), index);
            objects.put(singleObjectName, newLocator);
        }
    }
View Full Code Here

            throw new SyntaxException(UNKNOWN_LINE, "Object \"" + objectName + "\" has incorrect locator", e);
        }
    }

    private void addObjectToSpec(String objectName, String locatorType, CorrectionsRect corrections, String value) {
        Locator locator = new Locator(locatorType, value).withCorrections(corrections);
        if (objectName.contains("*")) {
            addMultiObject(objectName, locator);
        }
        else {
            pageSpec.addObject(objectName, locator);
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

   
    private PageSpec createMockedPageSpec(MockedPage page) {
        PageSpec pageSpec = new PageSpec();
       
        for (String objectName : page.getElements().keySet()) {
            pageSpec.getObjects().put(objectName, new Locator("id", objectName));
        }
        return pageSpec;
    }
View Full Code Here

TOP

Related Classes of net.mindengine.galen.specs.page.Locator

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.