4
4
-----
5
5
6
6
These days most of the web apps are using AJAX techniques. When a
7
- page is loaded to browser, the elements within that page may load at
8
- different time intervals. This makes locating elements difficult, if
9
- the element is not present in the DOM, it will raise
10
- `ElementNotVisibleException ` exception. Using waits, we can solve
11
- this issue. Waiting provides some time interval between actions
12
- performed - mostly locating element or any other operation with the
7
+ page is loaded by the browser, the elements within that page may load at
8
+ different time intervals. This makes locating elements difficult: if
9
+ an element is not yet present in the DOM, a locate function will raise
10
+ an `ElementNotVisibleException ` exception. Using waits, we can solve
11
+ this issue. Waiting provides some slack between actions
12
+ performed - mostly locating an element or any other operation with the
13
13
element.
14
14
15
15
Selenium Webdriver provides two types of waits - implicit & explicit.
16
- An explicit wait makes WebDriver to wait for a certain condition to
17
- occur before proceeding further with executions . An implicit wait
18
- makes WebDriver to poll the DOM for a certain amount of time when
16
+ An explicit wait makes WebDriver wait for a certain condition to
17
+ occur before proceeding further with execution . An implicit wait
18
+ makes WebDriver poll the DOM for a certain amount of time when
19
19
trying to locate an element.
20
20
21
21
22
22
Explicit Waits
23
23
~~~~~~~~~~~~~~
24
24
25
25
An explicit wait is code you define to wait for a certain condition
26
- to occur before proceeding further in the code. The worst case of
26
+ to occur before proceeding further in the code. The extreme case of
27
27
this is time.sleep(), which sets the condition to an exact time period
28
28
to wait. There are some convenience methods provided that help you
29
29
write code that will wait only as long as required. WebDriverWait in
@@ -47,17 +47,17 @@ accomplished.
47
47
driver.quit()
48
48
49
49
50
- This waits up to 10 seconds before throwing a TimeoutException or if
51
- it finds the element will return it in 0 - 10 seconds. WebDriverWait
50
+ This waits up to 10 seconds before throwing a TimeoutException unless
51
+ it finds the element to return within 10 seconds. WebDriverWait
52
52
by default calls the ExpectedCondition every 500 milliseconds until it
53
53
returns successfully. A successful return is for ExpectedCondition
54
54
type is Boolean return true or not null return value for all other
55
55
ExpectedCondition types.
56
56
57
57
**Expected Conditions **
58
58
59
- There are some common conditions that are frequent when
60
- automating web browsers. Listed below are Implementations of
59
+ There are some common conditions that are frequently of use when
60
+ automating web browsers. Listed below are the names of
61
61
each. Selenium Python binding provides some convienence methods so you
62
62
don't have to code an expected_condition class yourself or create your
63
63
own utility package for them.
@@ -72,7 +72,7 @@ own utility package for them.
72
72
- text_to_be_present_in_element_value
73
73
- frame_to_be_available_and_switch_to_it
74
74
- invisibility_of_element_located
75
- - element_to_be_clickable - it is Displayed and Enabled.
75
+ - element_to_be_clickable
76
76
- staleness_of
77
77
- element_to_be_selected
78
78
- element_located_to_be_selected
@@ -85,7 +85,7 @@ own utility package for them.
85
85
from selenium.webdriver.support import expected_conditions as EC
86
86
87
87
wait = WebDriverWait(driver, 10)
88
- element = wait.until(EC.element_to_be_clickable((By.ID,'someid')))
88
+ element = wait.until(EC.element_to_be_clickable((By.ID, 'someid')))
89
89
90
90
The expected_conditions module contains a set of predefined conditions
91
91
to use with WebDriverWait.
@@ -94,10 +94,10 @@ to use with WebDriverWait.
94
94
Implicit Waits
95
95
~~~~~~~~~~~~~~
96
96
97
- An implicit wait is to tell WebDriver to poll the DOM for a certain
98
- amount of time when trying to find an element or elements if they are
97
+ An implicit wait tells WebDriver to poll the DOM for a certain
98
+ amount of time when trying to find any element ( or elements)
99
99
not immediately available. The default setting is 0. Once set, the
100
- implicit wait is set for the life of the WebDriver object instance .
100
+ implicit wait is set for the life of the WebDriver object.
101
101
102
102
::
103
103
0 commit comments