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
cfe21a70
Commit
cfe21a70
authored
Oct 15, 2015
by
Jesse Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the helpers for Select objects by wrapping them in promises
parent
d367f7ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
common/test/acceptance/tests/helpers.py
+23
-4
No files found.
common/test/acceptance/tests/helpers.py
View file @
cfe21a70
...
...
@@ -21,6 +21,7 @@ from pymongo import MongoClient, ASCENDING
from
openedx.core.lib.tests.assertions.events
import
assert_event_matches
,
is_matching_event
,
EventMatchTolerates
from
xmodule.partitions.partitions
import
UserPartition
from
xmodule.partitions.tests.test_partitions
import
MockUserPartitionScheme
from
selenium.common.exceptions
import
StaleElementReferenceException
from
selenium.webdriver.support.select
import
Select
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions
as
EC
...
...
@@ -201,18 +202,36 @@ def enable_css_animations(page):
def
select_option_by_text
(
select_browser_query
,
option_text
):
"""
Chooses an option within a select by text (helper method for Select's select_by_visible_text method).
Wrap this in a Promise to prevent a StaleElementReferenceException
from being raised while the DOM is still being rewritten
"""
select
=
Select
(
select_browser_query
.
first
.
results
[
0
])
select
.
select_by_visible_text
(
option_text
)
def
select_option
(
query
,
value
):
try
:
select
=
Select
(
query
.
first
.
results
[
0
])
select
.
select_by_visible_text
(
value
)
return
True
except
StaleElementReferenceException
:
return
False
EmptyPromise
(
lambda
:
select_option
(
select_browser_query
,
option_text
),
'Selected option {}'
.
format
(
option_text
))
.
fulfill
()
def
get_selected_option_text
(
select_browser_query
):
"""
Returns the text value for the first selected option within a select.
Wrap this in a Promise to prevent a StaleElementReferenceException
from being raised while the DOM is still being rewritten
"""
select
=
Select
(
select_browser_query
.
first
.
results
[
0
])
return
select
.
first_selected_option
.
text
def
get_option
(
query
):
try
:
select
=
Select
(
select_browser_query
.
first
.
results
[
0
])
return
(
True
,
select
.
first_selected_option
.
text
)
except
StaleElementReferenceException
:
return
(
False
,
None
)
text
=
Promise
(
lambda
:
get_option
(
select_browser_query
),
'Retrieved selected option text'
)
.
fulfill
()
return
text
def
get_options
(
select_browser_query
):
"""
...
...
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