Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
b4036c66
Commit
b4036c66
authored
11 years ago
by
JonahStanley
Browse files
Options
Downloads
Patches
Plain Diff
Refactored the ui tests to use retry_on_exception
parent
ebc9fa9e
No related branches found
Branches containing commit
Tags
release-2021-05-05-18.30
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/terrain/ui_helpers.py
+14
-72
14 additions, 72 deletions
common/djangoapps/terrain/ui_helpers.py
lms/djangoapps/courseware/features/login.py
+2
-2
2 additions, 2 deletions
lms/djangoapps/courseware/features/login.py
with
16 additions
and
74 deletions
common/djangoapps/terrain/ui_helpers.py
+
14
−
72
View file @
b4036c66
...
...
@@ -145,42 +145,12 @@ def id_click(elem_id):
@world.absorb
def
css_fill
(
css_selector
,
text
,
index
=
0
,
max_attempts
=
5
):
assert
is_css_present
(
css_selector
)
attempt
=
0
result
=
False
while
attempt
<
max_attempts
:
try
:
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
fill
(
text
)
result
=
True
break
except
WebDriverException
:
# Occasionally, MathJax or other JavaScript can cover up
# an element temporarily.
# If this happens, wait a second, then try again
world
.
wait
(
1
)
attempt
+=
1
except
:
attempt
+=
1
assert_true
(
result
,
'
Filling {} did not work as expected
'
.
format
(
css_selector
))
return
world
.
retry_on_exception
(
lambda
:
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
fill
(
text
),
max_attempts
=
max_attempts
)
@world.absorb
def
click_link
(
partial_text
,
index
=
0
,
max_attempts
=
5
):
attempt
=
0
result
=
False
while
attempt
<
max_attempts
:
try
:
world
.
browser
.
find_link_by_partial_text
(
partial_text
)[
index
].
click
()
result
=
True
break
except
WebDriverException
:
# Occasionally, MathJax or other JavaScript can cover up
# an element temporarily.
# If this happens, wait a second, then try again
world
.
wait
(
1
)
attempt
+=
1
except
:
attempt
+=
1
assert_true
(
result
,
'
Clicking {} did not work as expected
'
.
format
(
partial_text
))
return
world
.
retry_on_exception
(
lambda
:
world
.
browser
.
find_link_by_partial_text
(
partial_text
)[
index
].
click
(),
max_attempts
=
max_attempts
)
@world.absorb
...
...
@@ -188,14 +158,7 @@ def css_text(css_selector, index=0, max_attempts=5):
# Wait for the css selector to appear
if
world
.
is_css_present
(
css_selector
):
attempt
=
0
while
attempt
<
max_attempts
:
try
:
return
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
text
break
except
:
attempt
+=
1
assert_true
(
attempt
<
max_attempts
,
'
Could not access {}
'
.
format
(
css_selector
))
return
world
.
retry_on_exception
(
lambda
:
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
text
,
max_attempts
=
max_attempts
)
else
:
return
""
...
...
@@ -205,14 +168,7 @@ def css_value(css_selector, index=0, max_attempts=5):
# Wait for the css selector to appear
if
world
.
is_css_present
(
css_selector
):
attempt
=
0
while
attempt
<
max_attempts
:
try
:
return
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
value
break
except
:
attempt
+=
1
assert_true
(
attempt
<
max_attempts
,
'
Could not access {}
'
.
format
(
css_selector
))
return
world
.
retry_on_exception
(
lambda
:
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
value
,
max_attempts
=
max_attempts
)
else
:
return
""
...
...
@@ -223,36 +179,18 @@ def css_html(css_selector, index=0, max_attempts=5):
Returns the HTML of a css_selector and will retry if there is a StaleElementReferenceException
"""
assert
is_css_present
(
css_selector
)
attempt
=
0
while
attempt
<
max_attempts
:
try
:
return
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
html
except
:
attempt
+=
1
assert_true
(
attempt
<
max_attempts
,
'
Ran out of attempts to access {}
'
.
format
(
css_selector
))
return
world
.
retry_on_exception
(
lambda
:
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
html
,
max_attempts
=
max_attempts
)
@world.absorb
def
css_has_class
(
css_selector
,
class_name
,
index
=
0
,
max_attempts
=
5
):
attempt
=
0
while
attempt
<
max_attempts
:
try
:
return
world
.
css_find
(
css_selector
)[
index
].
has_class
(
class_name
)
except
:
attempt
+=
1
assert_true
(
attempt
<
max_attempts
,
'
Ran out of attempts to access {}
'
.
format
(
css_selector
))
return
world
.
retry_on_exception
(
lambda
:
world
.
css_find
(
css_selector
)[
index
].
has_class
(
class_name
),
max_attempts
=
max_attempts
)
@world.absorb
def
css_visible
(
css_selector
,
index
=
0
,
max_attempts
=
5
):
assert
is_css_present
(
css_selector
)
attempt
=
0
while
attempt
<
max_attempts
:
try
:
return
except
:
attempt
+=
1
assert_true
(
attempt
<
max_attempts
,
'
Ran out of attempts to access {}
'
.
format
(
css_selector
))
return
world
.
retry_on_exception
(
lambda
:
world
.
browser
.
find_by_css
(
css_selector
)[
index
].
visible
,
max_attempts
=
max_attempts
)
@world.absorb
...
...
@@ -303,10 +241,14 @@ def is_mac():
@world.absorb
def
retry_on_exception
(
func
,
max_attempts
=
5
):
attempt
s
=
0
while
attempt
s
<
max_attempts
:
attempt
=
0
while
attempt
<
max_attempts
:
try
:
return
func
()
break
except
WebDriverException
:
world
.
wait
(
1
)
attempt
+=
1
except
:
attempts
+=
1
attempt
+=
1
assert_true
(
attempt
<
max_attempts
,
'
Ran out of attempts to execute {}
'
.
format
(
func
))
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/features/login.py
+
2
−
2
View file @
b4036c66
...
...
@@ -24,7 +24,7 @@ def i_submit_my_credentials_on_the_login_form(step):
def
submit_login_form
():
login_form
=
world
.
browser
.
find_by_css
(
'
form#login-form
'
)
login_form
.
find_by_name
(
'
submit
'
).
click
()
world
.
retry_on_excetion
(
submit_login_form
)
world
.
retry_on_exce
p
tion
(
submit_login_form
)
@step
(
u
'
I should see the login error message
"
([^
"
]*)
"
$
'
)
...
...
@@ -57,4 +57,4 @@ def fill_in_the_login_form(field, value):
login_form
=
world
.
browser
.
find_by_css
(
'
form#login-form
'
)
form_field
=
login_form
.
find_by_name
(
field
)
form_field
.
fill
(
value
)
world
.
retry_on_excetion
(
fill_login_form
)
world
.
retry_on_exce
p
tion
(
fill_login_form
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment