Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
66439943
Commit
66439943
authored
Jun 19, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an optional success lambda to css_click.
parent
9878c75b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
cms/djangoapps/contentstore/features/advanced-settings.py
+2
-8
common/djangoapps/terrain/ui_helpers.py
+12
-5
No files found.
cms/djangoapps/contentstore/features/advanced-settings.py
View file @
66439943
...
...
@@ -34,14 +34,8 @@ def press_the_notification_button(step, name):
save_clicked
=
lambda
:
world
.
is_css_not_present
(
'.is-shown.wrapper-notification-warning'
)
or
\
world
.
is_css_present
(
'.is-shown.wrapper-notification-error'
)
attempts
=
0
while
attempts
<
5
:
world
.
css_click
(
css
)
if
save_clicked
():
break
attempts
+=
1
assert_true
(
save_clicked
(),
'The save button was not clicked after 5 attempts.'
)
assert_true
(
world
.
css_click
(
css
,
success_condition
=
save_clicked
),
'The save button was not clicked after 5 attempts.'
)
@step
(
u'I edit the value of a policy key$'
)
...
...
common/djangoapps/terrain/ui_helpers.py
View file @
66439943
...
...
@@ -58,10 +58,16 @@ def css_find(css, wait_time=5):
@world.absorb
def
css_click
(
css_selector
,
index
=
0
,
attempts
=
5
):
def
css_click
(
css_selector
,
index
=
0
,
attempts
=
5
,
success_condition
=
lambda
:
True
):
"""
Perform a click on a CSS selector, retrying if it initially fails
This function will return if the click worked (since it is try/excepting all errors)
Perform a click on a CSS selector, retrying if it initially fails.
This function handles errors that may be thrown if the component cannot be clicked on.
However, there are cases where an error may not be thrown, and yet the operation did not
actually succeed. For those cases, a success_condition lambda can be supplied to verify that the click worked.
This function will return True if the click worked (taking into account both errors and the optional
success_condition).
"""
assert
is_css_present
(
css_selector
)
attempt
=
0
...
...
@@ -69,8 +75,9 @@ def css_click(css_selector, index=0, attempts=5):
while
attempt
<
attempts
:
try
:
world
.
css_find
(
css_selector
)[
index
]
.
click
()
result
=
True
break
if
success_condition
():
result
=
True
break
except
WebDriverException
:
# Occasionally, MathJax or other JavaScript can cover up
# an element temporarily.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment