Skip to content

Commit 6841f91

Browse files
committed
Adding new tests for disable, hidden or invisible 'option' elements, inspired by #379. The tests are based on the current drivers' behavior, not sure if it is correct or not.
1 parent 951b3a9 commit 6841f91

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

common/src/web/selectPage.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,12 @@
5454
<option value="cheddar">Avonlea Clothbound Cheddar</option>
5555
</select>
5656

57+
<select id="visibility">
58+
<option value="regular" class="regular">Regular</option>
59+
<option value="disabled" disabled="disabled" class="disabled">Disabled</option>
60+
<option value="hidden" style="visibility: hidden;" class="hidden">Hidden</option>
61+
<option value="invisible" style="display: none;" class="invisible">Invisible</option>
62+
</select>
63+
5764
</body>
5865
</html>

java/client/test/org/openqa/selenium/SelectElementHandlingTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
import static org.hamcrest.Matchers.is;
2121
import static org.junit.Assert.assertThat;
2222
import static org.junit.Assert.assertTrue;
23+
import static org.openqa.selenium.testing.Driver.HTMLUNIT;
24+
import static org.openqa.selenium.testing.Driver.MARIONETTE;
2325

2426
import org.junit.Test;
2527
import org.openqa.selenium.testing.JUnit4TestBase;
28+
import org.openqa.selenium.testing.NotYetImplemented;
2629

2730
import java.util.List;
2831

@@ -126,4 +129,32 @@ public void testCanSelectFromMultipleSelectWhereValueIsBelowVisibleRange() {
126129
option.click();
127130
assertThat(option.isSelected(), is(true));
128131
}
132+
133+
@Test
134+
@NotYetImplemented(MARIONETTE)
135+
public void testCannotSetDisabledOption() {
136+
driver.get(pages.selectPage);
137+
WebElement element = driver.findElement(By.cssSelector("#visibility .disabled"));
138+
element.click();
139+
assertTrue("Expected to not be selected", !element.isSelected());
140+
}
141+
142+
@Test
143+
@NotYetImplemented(HTMLUNIT)
144+
public void testCanSetHiddenOption() {
145+
driver.get(pages.selectPage);
146+
WebElement element = driver.findElement(By.cssSelector("#visibility .hidden"));
147+
element.click();
148+
assertTrue("Expected to be selected", element.isSelected());
149+
}
150+
151+
@Test
152+
@NotYetImplemented(HTMLUNIT)
153+
public void testCanSetInvisibleOption() {
154+
driver.get(pages.selectPage);
155+
WebElement element = driver.findElement(By.cssSelector("#visibility .invisible"));
156+
element.click();
157+
assertTrue("Expected to be selected", element.isSelected());
158+
}
159+
129160
}

0 commit comments

Comments
 (0)