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
b4036c66
Commit
b4036c66
authored
Jul 11, 2013
by
JonahStanley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the ui tests to use retry_on_exception
parent
ebc9fa9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
74 deletions
+16
-74
common/djangoapps/terrain/ui_helpers.py
+14
-72
lms/djangoapps/courseware/features/login.py
+2
-2
No files found.
common/djangoapps/terrain/ui_helpers.py
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
))
lms/djangoapps/courseware/features/login.py
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
)
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