Package org.seleniumhq.selenium.fluent

Examples of org.seleniumhq.selenium.fluent.FluentSelect$GetFirstSelectedOption


        when(we.getAttribute("multiple")).thenReturn("true");
        when(we.findElements(By.xpath(".//option[@value = \"bar\"]"))).thenReturn(newArrayList(we2, we3));
        when(we2.isSelected()).thenReturn(true);
        when(we3.isSelected()).thenReturn(false);

        FluentSelect fs = fwd.select().selectByValue("bar");

        assertThat(fs, notNullValue());

        verify(wd).findElement(By.tagName("select"));
        verify(we, times(2)).getTagName();
View Full Code Here


        WebDriver wd = mock(WebDriver.class);
        WebElement we = mock(WebElement.class);
        final Select wdSelect = mock(Select.class);

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }
        };
        select.selectByValue("humphrey");

        verify(wdSelect, times(1)).selectByValue("humphrey");
        verifyNoMoreInteractions(wd, we, wdSelect);
    }
View Full Code Here

        final Select wdSelect = mock(Select.class);

        final WebDriverException fooE = new WebDriverException("foo");
        doThrow(fooE).when(wdSelect).selectByValue("humphrey");

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }

            @Override
            protected Void executeAndWrapReThrowIfNeeded(Execution execution, Internal.WebElementHolder currentElement, Context ctx, boolean expectedToBeThere) {
                try {
                    execution.execute();
                    fail("should have barfed");
                } catch (AssertionError e) {
                    throw e;
                } catch (Throwable e) {
                    assertTrue(e == fooE);
                }
                throw new RuntimeException("bar");
            }
        };

        try {
            select.selectByValue("humphrey");
        } catch (RuntimeException e) {
            assertThat(e.getMessage(), equalTo("bar"));
        }

        verify(wdSelect).selectByValue("humphrey");
View Full Code Here

        WebDriver wd = mock(WebDriver.class);
        WebElement we = mock(WebElement.class);
        final Select wdSelect = mock(Select.class);

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }
        };
        select.selectByIndex(444);

        verify(wdSelect, times(1)).selectByIndex(444);

        verifyNoMoreInteractions(wd, we, wdSelect);
    }
View Full Code Here

        final Select wdSelect = mock(Select.class);

        final WebDriverException fooE = new WebDriverException("foo");
        doThrow(fooE).when(wdSelect).selectByIndex(444);

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }

            @Override
            protected Void executeAndWrapReThrowIfNeeded(Execution execution, Internal.WebElementHolder currentElement, Context ctx, boolean expectedToBeThere) {
                try {
                    execution.execute();
                    fail("should have barfed");
                } catch (AssertionError e) {
                    throw e;
                } catch (Throwable e) {
                    assertTrue(e == fooE);
                }
                throw new RuntimeException("bar");
            }
        };

        try {
            select.selectByIndex(444);
        } catch (RuntimeException e) {
            assertThat(e.getMessage(), equalTo("bar"));
        }

        verify(wdSelect).selectByIndex(444);
View Full Code Here

        WebDriver wd = mock(WebDriver.class);
        WebElement we = mock(WebElement.class);
        final Select wdSelect = mock(Select.class);

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }
        };
        select.selectByVisibleText("humphrey");

        verify(wdSelect, times(1)).selectByVisibleText("humphrey");

        verifyNoMoreInteractions(wd, we, wdSelect);
    }
View Full Code Here

        final Select wdSelect = mock(Select.class);

        final WebDriverException fooE = new WebDriverException("foo");
        doThrow(fooE).when(wdSelect).selectByVisibleText("humphrey");

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }

            @Override
            protected Void executeAndWrapReThrowIfNeeded(Execution execution, Internal.WebElementHolder currentElement, Context ctx, boolean expectedToBeThere) {
                try {
                    execution.execute();
                    fail("should have barfed");
                } catch (AssertionError e) {
                    throw e;
                } catch (Throwable e) {
                    assertTrue(e == fooE);
                }
                throw new RuntimeException("bar");
            }
        };

        try {
            select.selectByVisibleText("humphrey");
        } catch (RuntimeException e) {
            assertThat(e.getMessage(), equalTo("bar"));
        }

        verify(wdSelect).selectByVisibleText("humphrey");
View Full Code Here

        WebDriver wd = mock(WebDriver.class);
        WebElement we = mock(WebElement.class);
        final Select wdSelect = mock(Select.class);

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }
        };
        select.deselectAll();

        verify(wdSelect, times(1)).deselectAll();
        verifyNoMoreInteractions(wd, we, wdSelect);
    }
View Full Code Here

        final Select wdSelect = mock(Select.class);

        final WebDriverException fooE = new WebDriverException("foo");
        doThrow(fooE).when(wdSelect).deselectAll();

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }

            @Override
            protected Void executeAndWrapReThrowIfNeeded(Execution execution, Internal.WebElementHolder currentElement, Context ctx, boolean expectedToBeThere) {
                try {
                    execution.execute();
                    fail("should have barfed");
                } catch (AssertionError e) {
                    throw e;
                } catch (Throwable e) {
                    assertTrue(e == fooE);
                }
                throw new RuntimeException("bar");
            }
        };

        try {
            select.deselectAll();
        } catch (RuntimeException e) {
            assertThat(e.getMessage(), equalTo("bar"));
        }

        verify(wdSelect).deselectAll();
View Full Code Here

        WebDriver wd = mock(WebDriver.class);
        WebElement we = mock(WebElement.class);
        final Select wdSelect = mock(Select.class);

        FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
            @Override
            protected Select getSelect() {
                return wdSelect;
            }
        };
        select.deselectByValue("humphrey");

        verify(wdSelect, times(1)).deselectByValue("humphrey");
        verifyNoMoreInteractions(wd, we, wdSelect);
    }
View Full Code Here

TOP

Related Classes of org.seleniumhq.selenium.fluent.FluentSelect$GetFirstSelectedOption

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.