Skip to content

Commit

Permalink
Adding new tests for disable, hidden or invisible 'option' elements, …
Browse files Browse the repository at this point in the history
…inspired by #379. The tests are based on the current drivers' behavior, not sure if it is correct or not.
  • Loading branch information
barancev committed Nov 27, 2017
1 parent 951b3a9 commit 6841f91
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/src/web/selectPage.html
Expand Up @@ -54,5 +54,12 @@
<option value="cheddar">Avonlea Clothbound Cheddar</option>
</select>

<select id="visibility">
<option value="regular" class="regular">Regular</option>
<option value="disabled" disabled="disabled" class="disabled">Disabled</option>
<option value="hidden" style="visibility: hidden;" class="hidden">Hidden</option>
<option value="invisible" style="display: none;" class="invisible">Invisible</option>
</select>

</body>
</html>
Expand Up @@ -20,9 +20,12 @@
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.openqa.selenium.testing.Driver.HTMLUNIT;
import static org.openqa.selenium.testing.Driver.MARIONETTE;

import org.junit.Test;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.NotYetImplemented;

import java.util.List;

Expand Down Expand Up @@ -126,4 +129,32 @@ public void testCanSelectFromMultipleSelectWhereValueIsBelowVisibleRange() {
option.click();
assertThat(option.isSelected(), is(true));
}

@Test
@NotYetImplemented(MARIONETTE)
public void testCannotSetDisabledOption() {
driver.get(pages.selectPage);
WebElement element = driver.findElement(By.cssSelector("#visibility .disabled"));
element.click();
assertTrue("Expected to not be selected", !element.isSelected());
}

@Test
@NotYetImplemented(HTMLUNIT)
public void testCanSetHiddenOption() {
driver.get(pages.selectPage);
WebElement element = driver.findElement(By.cssSelector("#visibility .hidden"));
element.click();
assertTrue("Expected to be selected", element.isSelected());
}

@Test
@NotYetImplemented(HTMLUNIT)
public void testCanSetInvisibleOption() {
driver.get(pages.selectPage);
WebElement element = driver.findElement(By.cssSelector("#visibility .invisible"));
element.click();
assertTrue("Expected to be selected", element.isSelected());
}

}

0 comments on commit 6841f91

Please sign in to comment.