Package org.openqa.selenium

Examples of org.openqa.selenium.By.findElement()


        assertThat(fooBar.toString(), is("FluentBy.attribute: foo = 'bar'"));

        FindsByXPathSearchContext context = mock(FindsByXPathSearchContext.class);
        WebElement we = mock(WebElement.class);
        when(context.findElementByXPath(".//*[@foo = 'bar']")).thenReturn(we);
        WebElement bar = fooBar.findElement(context);
        assertThat(bar, is(we));

        // last of ..

        By lastFooBar = FluentBy.last(fooBar);
View Full Code Here


        assertThat(actual, is("FluentBy.notAttribute: foo"));

        FindsByXPathSearchContext context = mock(FindsByXPathSearchContext.class);
        WebElement we = mock(WebElement.class);
        when(context.findElementByXPath(".//*[not(@foo)]")).thenReturn(we);
        WebElement bar = notFoo.findElement(context);

        assertThat(bar, is(we));

        // last of ..

View Full Code Here

        FindsByXPathSearchContext context = mock(FindsByXPathSearchContext.class);
        WebElement we = mock(WebElement.class);
        WebElement we2 = mock(WebElement.class);

        when(context.findElementByXPath(".//*[@foo]")).thenReturn(we);
        WebElement bar = fooBar.findElement(context);
        assertThat(bar, is(we));

        when(context.findElementsByXPath(".//*[@foo]")).thenReturn(newArrayList(we, we2));
        List<WebElement> bars = fooBar.findElements(context);
        assertThat(bars.get(0), is(we));
View Full Code Here

        By lastFooBar = FluentBy.last();
        assertThat(lastFooBar.toString(), is("FluentBy.last()"));

        when(context.findElementByXPath(".//*[position() = last()]")).thenReturn(we);
        WebElement lastBar = lastFooBar.findElement(context);
        assertThat(lastBar, is(we));
    }

    @Test
    public void strict_class_name() throws IllegalAccessException {
View Full Code Here

        By scn = FluentBy.strictClassName("blort");
        assertThat(scn.toString(), is("FluentBy.strictClassName: blort"));

        when(context.findElementByXPath(".//*[@class = 'blort']")).thenReturn(we);
        WebElement blort = scn.findElement(context);
        assertThat(blort, is(we));

        when(context.findElementsByXPath(".//*[@class = 'blort']")).thenReturn(newArrayList(we, we2));
        List<WebElement> blorts = scn.findElements(context);
        assertThat(blorts.get(0), is(we));
View Full Code Here

        By aB = FluentBy.composite(new By.ByTagName("a"), new By.ByClassName("b"));
        assertThat(aB.toString(), is("FluentBy.composite([By.tagName: a, By.className: b])"));

        when(context.findElementByXPath(".//a[contains(concat(' ',normalize-space(@class),' '),' b ')]")).thenReturn(we);
        WebElement blort = aB.findElement(context);
        assertThat(blort, is(we));

        when(context.findElementsByXPath(".//a[contains(concat(' ',normalize-space(@class),' '),' b ')]")).thenReturn(newArrayList(we, we2));
        List<WebElement> blorts = aB.findElements(context);
        assertThat(blorts.get(0), is(we));
View Full Code Here

        By aB = FluentBy.composite(new By.ByTagName("a"), new FluentBy.ByAttribute("b", null));
        assertThat(aB.toString(), is("FluentBy.composite([By.tagName: a, FluentBy.attribute: b])"));

        when(context.findElementByXPath(".//a[@b]")).thenReturn(we);
        WebElement blort = aB.findElement(context);
        //verifyNoMoreInteractions(context);
        assertThat(blort, is(we));

        when(context.findElementsByXPath(".//a[@b]")).thenReturn(newArrayList(we, we2));
        List<WebElement> blorts = aB.findElements(context);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.