List of usage examples for org.openqa.selenium WebElement isSelected
boolean isSelected();
From source file:org.zanata.page.webtrans.EditorPage.java
License:Open Source License
public EditorPage setSyntaxHighlighting(boolean option) { log.info("Set syntax highlight to {}", option); openConfigurationPanel();/*from w w w . j a v a 2 s. co m*/ WebElement highlight = readyElement(By.id(EDITOR_SYNTAXHIGHLIGHT)); if (highlight.isSelected() != option) { highlight.click(); } return new EditorPage(getDriver()); }
From source file:ru.mystamps.web.tests.page.AddSeriesPage.java
License:Open Source License
public void fillPerforated(boolean turnOn) { WebElement el = getElementByName("perforated"); if (el.isSelected()) { if (!turnOn) { el.click();//w w w.j ava 2s .c o m } } else { if (turnOn) { el.click(); } } }
From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java
License:Apache License
@Test void canFireEventForWebElementIsSelected() { Fixture fixture = new Fixture(); final WebElement mockedElement = mock(WebElement.class); when(fixture.mockedDriver.findElement(By.id("id"))).thenReturn(mockedElement); when(mockedElement.isSelected()).thenReturn(true); assertEquals(fixture.driver.findElement(By.id("id")).isSelected(), true); verify(fixture.mockedDriver, times(1)).findElement(By.id("id")); verifyNoMoreInteractions(fixture.mockedDriver); verify(fixture.listener, times(1)).beforeFindElement(fixture.mockedDriver, By.id("id")); verify(fixture.listener, times(1)).afterFindElement(mockedElement, fixture.mockedDriver, By.id("id")); verify(mockedElement, times(1)).isSelected(); verifyNoMoreInteractions(mockedElement); verify(fixture.listener, times(1)).beforeIsSelected(mockedElement); verify(fixture.listener, times(1)).afterIsSelected(true, mockedElement); verifyNoMoreInteractions(fixture.listener); }
From source file:ru.stqa.selenium.wait.ClientSideImplicitWaitWrapperTest.java
License:Apache License
@Test public void isSelectedShouldImplicitlyWaitForTheElementToBeVisible() { final WebElement mockedElement = mock(WebElement.class); when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement); when(mockedElement.isSelected()).thenThrow(ElementNotVisibleException.class) .thenThrow(ElementNotVisibleException.class).thenReturn(true); boolean selected = driver.findElement(By.name("foo")).isSelected(); assertThat(clock.now(), is(200L));/*from w w w . j a v a 2 s. com*/ assertThat(selected, is(true)); verify(mockedDriver, times(1)).findElement(By.name("foo")); verify(mockedElement, times(3)).isSelected(); }
From source file:ru.stqa.selenium.wait.ClientSideImplicitWaitWrapperTest.java
License:Apache License
@Test public void isSelectedShouldImplicitlyWaitForTheElementToBeVisibleEvenIfTheElementIsNotSelected() { final WebElement mockedElement = mock(WebElement.class); when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement); when(mockedElement.isSelected()).thenThrow(ElementNotVisibleException.class) .thenThrow(ElementNotVisibleException.class).thenReturn(false); boolean selected = driver.findElement(By.name("foo")).isSelected(); assertThat(clock.now(), is(200L));/* w ww.j a v a 2 s . c om*/ assertThat(selected, is(false)); verify(mockedDriver, times(1)).findElement(By.name("foo")); verify(mockedElement, times(3)).isSelected(); }
From source file:ru.stqa.selenium.wait.ClientSideImplicitWaitWrapperTest.java
License:Apache License
@Test public void isSelectedShouldThrowIfTheElementIsNotVisible() { final WebElement mockedElement = mock(WebElement.class); when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement); when(mockedElement.isSelected()).thenThrow(ElementNotVisibleException.class); try {//from ww w . j a va2s. c om driver.findElement(By.name("foo")).isSelected(); fail("Exception expected"); } catch (Throwable t) { assertThat(t, instanceOf(ElementNotVisibleException.class)); } assertThat(clock.now(), is(1000L)); verify(mockedDriver, times(1)).findElement(By.name("foo")); verify(mockedElement, times(11)).isSelected(); }
From source file:ru.stqa.selenium.wait.ImplicitlyWaitingWebDriverTest.java
License:Apache License
@Test void isSelectedShouldImplicitlyWaitForTheElementToBeVisible() { final WebElement mockedElement = mock(WebElement.class); when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement); when(mockedElement.isSelected()).thenThrow(ElementNotVisibleException.class) .thenThrow(ElementNotVisibleException.class).thenReturn(true); boolean selected = driver.findElement(By.name("foo")).isSelected(); assertThat(clock.now(), is(200L));/* w w w. j av a 2s . com*/ assertThat(selected, is(true)); verify(mockedDriver, times(1)).findElement(By.name("foo")); verify(mockedElement, times(3)).isSelected(); }
From source file:ru.stqa.selenium.wait.ImplicitlyWaitingWebDriverTest.java
License:Apache License
@Test void isSelectedShouldImplicitlyWaitForTheElementToBeVisibleEvenIfTheElementIsNotSelected() { final WebElement mockedElement = mock(WebElement.class); when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement); when(mockedElement.isSelected()).thenThrow(new ElementNotVisibleException("")) .thenThrow(new ElementNotVisibleException("")).thenReturn(false); boolean selected = driver.findElement(By.name("foo")).isSelected(); assertThat(clock.now(), is(200L));//from w ww . ja v a 2 s. c om assertThat(selected, is(false)); verify(mockedDriver, times(1)).findElement(By.name("foo")); verify(mockedElement, times(3)).isSelected(); }
From source file:ru.stqa.selenium.wait.ImplicitlyWaitingWebDriverTest.java
License:Apache License
@Test void isSelectedShouldThrowIfTheElementIsNotVisible() { final WebElement mockedElement = mock(WebElement.class); when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement); when(mockedElement.isSelected()).thenThrow(ElementNotVisibleException.class); assertThrows(ElementNotVisibleException.class, () -> driver.findElement(By.name("foo")).isSelected()); assertThat(clock.now(), is(1000L));/* w w w. jav a 2 s . c o m*/ verify(mockedDriver, times(1)).findElement(By.name("foo")); verify(mockedElement, times(11)).isSelected(); }
From source file:ru.stqa.selenium.wait.RepeatableActions.java
License:Apache License
public static RepeatableAction<WebElement, Boolean> checkIsSelected() { return new AbstractRepeatableAction<WebElement, Boolean>() { @Override//from w w w . j a v a 2s . co m public Boolean apply(WebElement element) { return element.isSelected(); } @Override public boolean shouldIgnoreException(Throwable t) { return t instanceof ElementNotVisibleException; } }; }