![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0281.jpg)
Figure 15-3. Using the Debug toolbar to find locators
A Common Selenium Technique: Explicit Waits
Here’s the first of the two “wait” helper functions:
functional_tests/test_login.py (ch15l014).
import
time
[
...
]
def
switch_to_new_window
(
self
,
text_in_title
):
retries
=
60
while
retries
>
0
:
for
handle
in
self
.
browser
.
window_handles
:
self
.
browser
.
switch_to_window
(
handle
)
if
text_in_title
in
self
.
browser
.
title
:
return
retries
-=
1
time
.
sleep
(
0.5
)
self
.
fail
(
'could not find window'
)
De-spiking
|
253