File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
resources/html/javascript
src/SeleniumLibrary/keywords Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,16 @@ Alert Should Be Present with custom timeout
120
120
... Alert Should Be Present timeout=1ms
121
121
Alert Should Be Present Alert after 500ms! ACCEPT 3s
122
122
123
+ Handle Alert when popup window closes
124
+ [Documentation] Popup window is closed by javascript while
125
+ ... 'Handle Alert' keyword is waiting for alert
126
+ ... FAIL GLOB: An exception occurred waiting for alert*
127
+ [Setup] Go To Page "javascript/self_closing_popup.html"
128
+ Click Button Self Closing
129
+ ${handle } = Switch Window NEW
130
+ Handle Alert timeout=10s
131
+ [Teardown] Switch Window ${handle }
132
+
123
133
*** Keywords ***
124
134
Wait For Title Change
125
135
[Arguments] ${expected }
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < title > Self Closing Popup</ title >
4
+ < script type ="text/javascript ">
5
+ function openCloseAfterDelay ( ) {
6
+ var popupWindow = window . open ( "alert.html" ) ;
7
+ window . setTimeout ( function ( ) {
8
+ popupWindow . close ( ) ;
9
+ } , 500 ) ;
10
+ }
11
+ </ script >
12
+ </ head >
13
+ < body >
14
+ < p > When you click this button, another window / tab will open and automatically close 0.5s later</ p >
15
+ < button onclick ="openCloseAfterDelay() "> Self Closing</ button >
16
+ </ body >
17
+ </ html >
Original file line number Diff line number Diff line change 14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
17
- from selenium .common .exceptions import WebDriverException
17
+ from selenium .common .exceptions import TimeoutException , WebDriverException
18
18
from selenium .webdriver .support import expected_conditions as EC
19
19
from selenium .webdriver .support .ui import WebDriverWait
20
20
@@ -133,6 +133,9 @@ def _wait_alert(self, timeout=None):
133
133
wait = WebDriverWait (self .driver , timeout )
134
134
try :
135
135
return wait .until (EC .alert_is_present ())
136
- except WebDriverException :
136
+ except TimeoutException :
137
137
raise AssertionError ('Alert not found in %s.'
138
- % secs_to_timestr (timeout ))
138
+ % secs_to_timestr (timeout ))
139
+ except WebDriverException as err :
140
+ raise AssertionError ('An exception occurred waiting for alert: %s'
141
+ % err )
You can’t perform that action at this time.
0 commit comments