Skip to content

Commit 300cd3f

Browse files
carlosgcamposlmtierney
authored andcommitted
[py] make tests to check clicking on disabled element work for w3c compliant drivers (#5561)
They are currently mrked as expected failure, but we can actually test both behaviors. Check that selection doesn't change for w3c drivers.
1 parent cf8b24f commit 300cd3f

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

py/test/selenium/webdriver/common/select_class_tests.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ def testSelectByIndexSingle(driver, pages):
4545
@pytest.mark.xfail_chrome
4646
@pytest.mark.xfail_firefox
4747
@pytest.mark.xfail_remote
48-
@pytest.mark.xfail_marionette
49-
@pytest.mark.xfail_safari
50-
def testSelectDisabledByIndexShouldThrowException(driver, pages):
48+
@pytest.mark.xfail_marionette(reason='https://bugzilla.mozilla.org/show_bug.cgi?id=1429403')
49+
def testSelectDisabledByIndex(driver, pages):
5150
pages.load("formPage.html")
5251
sel = Select(driver.find_element(By.NAME, disabledSelect['name']))
53-
with pytest.raises(ElementNotSelectableException):
52+
if driver.w3c:
53+
selected = sel.first_selected_option
5454
sel.select_by_index(1)
55+
assert selected == sel.first_selected_option
56+
else:
57+
with pytest.raises(ElementNotSelectableException):
58+
sel.select_by_index(1)
5559

5660

5761
def testSelectByValueSingle(driver, pages):
@@ -67,13 +71,17 @@ def testSelectByValueSingle(driver, pages):
6771
@pytest.mark.xfail_chrome
6872
@pytest.mark.xfail_firefox
6973
@pytest.mark.xfail_remote
70-
@pytest.mark.xfail_marionette
71-
@pytest.mark.xfail_safari
72-
def testSelectDisabledByValueShouldThrowException(driver, pages):
74+
@pytest.mark.xfail_marionette(reason='https://bugzilla.mozilla.org/show_bug.cgi?id=1429403')
75+
def testSelectDisabledByValue(driver, pages):
7376
pages.load("formPage.html")
7477
sel = Select(driver.find_element(By.NAME, disabledSelect['name']))
75-
with pytest.raises(ElementNotSelectableException):
78+
if driver.w3c:
79+
selected = sel.first_selected_option
7680
sel.select_by_value('bar')
81+
assert selected == sel.first_selected_option
82+
else:
83+
with pytest.raises(ElementNotSelectableException):
84+
sel.select_by_value('bar')
7785

7886

7987
def testSelectByVisibleTextSingle(driver, pages):
@@ -103,13 +111,17 @@ def testSelectByVisibleTextShouldNormalizeSpaces(driver, pages):
103111
@pytest.mark.xfail_chrome
104112
@pytest.mark.xfail_firefox
105113
@pytest.mark.xfail_remote
106-
@pytest.mark.xfail_marionette
107-
@pytest.mark.xfail_safari
108-
def testSelectDisabledByVisibleTextShouldThrowException(driver, pages):
114+
@pytest.mark.xfail_marionette(reason='https://bugzilla.mozilla.org/show_bug.cgi?id=1429403')
115+
def testSelectDisabledByVisibleText(driver, pages):
109116
pages.load("formPage.html")
110117
sel = Select(driver.find_element(By.NAME, disabledSelect['name']))
111-
with pytest.raises(ElementNotSelectableException):
118+
if driver.w3c:
119+
selected = sel.first_selected_option
112120
sel.select_by_visible_text('Bar')
121+
assert selected == sel.first_selected_option
122+
else:
123+
with pytest.raises(ElementNotSelectableException):
124+
sel.select_by_visible_text('Bar')
113125

114126

115127
def testSelectByIndexMultiple(driver, pages):

0 commit comments

Comments
 (0)