Skip to content

Commit 1f4baf4

Browse files
committed
Add examples to Wait For Condition.
See #925 about doc enhancements in general and #188 about exactly this enhancement.
1 parent d8821b8 commit 1f4baf4

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/SeleniumLibrary/keywords/waiting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def wait_for_condition(self, condition, timeout=None, error=None):
3636
and their default value.
3737
3838
``error`` can be used to override the default error message.
39+
40+
Examples:
41+
| `Wait For Condition` | return document.title == "New Title" |
42+
| `Wait For Condition` | return jQuery.active == 0 |
43+
| `Wait For Condition` | style = document.querySelector('h1').style; return style.background == "red" && style.color == "white" |
3944
"""
4045
if 'return' not in condition:
4146
raise ValueError("Condition '%s' did not have mandatory 'return'."

test/acceptance/keywords/waiting.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Force Tags Known Issue Internet Explorer
77
Wait For Condition
88
Title Should Be Original
99
Wait For Condition return window.document.title == "Changed"
10+
Wait For Condition style = document.querySelector('#content').style; return style.background == "red" && style.color == "white"
1011
Run Keyword And Expect Error
1112
... Condition 'return window.document.title == "Invalid"' did not become true in 100 milliseconds.
1213
... Wait For Condition return window.document.title == "Invalid" ${0.1}

test/resources/html/javascript/delayed_events.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</head>
4848

4949
<body onload="modifyAfterDelay()">
50-
<div id="content">This is content</div>
50+
<div id="content" style="color: white; background: red">This is content</div>
5151
<div id="container"></div>
5252
<div id="not_present">Element that should disappear</div>
5353
<div id="hidden" style="display:none;">Initially hidden content</div>

0 commit comments

Comments
 (0)