|
19 | 19 |
|
20 | 20 | from selenium.common.exceptions import ( |
21 | 21 | ElementNotVisibleException, |
| 22 | + ElementNotInteractableException, |
22 | 23 | InvalidElementStateException) |
23 | 24 | from selenium.webdriver.common.by import By |
24 | 25 |
|
@@ -67,30 +68,42 @@ def testHiddenInputElementsAreNeverVisible(driver, pages): |
67 | 68 | def testShouldNotBeAbleToClickOnAnElementThatIsNotDisplayed(driver, pages): |
68 | 69 | pages.load("javascriptPage.html") |
69 | 70 | element = driver.find_element(by=By.ID, value="unclickable") |
70 | | - with pytest.raises(ElementNotVisibleException): |
| 71 | + try: |
71 | 72 | element.click() |
| 73 | + assert 1 == 0, "should have thrown an exception" |
| 74 | + except (ElementNotVisibleException, ElementNotInteractableException) as e: |
| 75 | + pass |
72 | 76 |
|
73 | 77 |
|
74 | 78 | def testShouldNotBeAbleToToggleAnElementThatIsNotDisplayed(driver, pages): |
75 | 79 | pages.load("javascriptPage.html") |
76 | 80 | element = driver.find_element(by=By.ID, value="untogglable") |
77 | | - with pytest.raises(ElementNotVisibleException): |
| 81 | + try: |
78 | 82 | element.click() |
| 83 | + assert 1 == 0, "should have thrown an exception" |
| 84 | + except (ElementNotVisibleException, ElementNotInteractableException) as e: |
| 85 | + pass |
79 | 86 |
|
80 | 87 |
|
81 | 88 | def testShouldNotBeAbleToSelectAnElementThatIsNotDisplayed(driver, pages): |
82 | 89 | pages.load("javascriptPage.html") |
83 | 90 | element = driver.find_element(by=By.ID, value="untogglable") |
84 | | - with pytest.raises(ElementNotVisibleException): |
| 91 | + try: |
85 | 92 | element.click() |
| 93 | + assert 1 == 0, "should have thrown an exception" |
| 94 | + except (ElementNotVisibleException, ElementNotInteractableException) as e: |
| 95 | + pass |
86 | 96 |
|
87 | 97 |
|
88 | 98 | @pytest.mark.xfail_phantomjs(raises=InvalidElementStateException) |
89 | 99 | def testShouldNotBeAbleToTypeAnElementThatIsNotDisplayed(driver, pages): |
90 | 100 | pages.load("javascriptPage.html") |
91 | 101 | element = driver.find_element(by=By.ID, value="unclickable") |
92 | | - with pytest.raises(ElementNotVisibleException): |
| 102 | + try: |
93 | 103 | element.send_keys("You don't see me") |
| 104 | + assert 1 == 0, "should have thrown an exception" |
| 105 | + except (ElementNotVisibleException, ElementNotInteractableException) as e: |
| 106 | + pass |
94 | 107 | assert element.get_attribute("value") != "You don't see me" |
95 | 108 |
|
96 | 109 |
|
|
0 commit comments