Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
ed584d91
Commit
ed584d91
authored
May 02, 2016
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tune PayPal acceptance tests
Also reduce coupon creation wait times.
parent
2261bfdc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
15 deletions
+39
-15
acceptance_tests/expected_conditions.py
+20
-0
acceptance_tests/mixins.py
+13
-2
acceptance_tests/pages/coupons.py
+6
-13
No files found.
acceptance_tests/expected_conditions.py
0 → 100644
View file @
ed584d91
"""Expectations for use with Selenium's WebDriverWait."""
class
option_selected
(
object
):
"""An expectation for checking that an option has been selected."""
def
__init__
(
self
,
select
,
text
):
self
.
select
=
select
self
.
text
=
text
def
__call__
(
self
,
_
):
return
self
.
select
.
first_selected_option
.
text
==
self
.
text
class
input_provided
(
object
):
"""An expectation for checking that input values have been provided."""
def
__init__
(
self
,
*
elements
):
self
.
elements
=
elements
def
__call__
(
self
,
_
):
return
all
([
element
.
get_attribute
(
'value'
)
for
element
in
self
.
elements
])
acceptance_tests/mixins.py
View file @
ed584d91
...
...
@@ -26,6 +26,7 @@ from acceptance_tests.config import (
PAYPAL_EMAIL
,
LMS_HTTPS
)
from
acceptance_tests.expected_conditions
import
input_provided
from
acceptance_tests.pages
import
LMSLoginPage
,
LMSDashboardPage
,
LMSRegistrationPage
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -199,8 +200,18 @@ class PaymentMixin(object):
# Log into PayPal
self
.
browser
.
switch_to
.
frame
(
iframe
)
self
.
browser
.
find_element_by_css_selector
(
'input#email'
)
.
send_keys
(
PAYPAL_EMAIL
)
self
.
browser
.
find_element_by_css_selector
(
'input#password'
)
.
send_keys
(
PAYPAL_PASSWORD
)
email
=
self
.
browser
.
find_element_by_css_selector
(
'input#email'
)
password
=
self
.
browser
.
find_element_by_css_selector
(
'input#password'
)
email
.
send_keys
(
PAYPAL_EMAIL
)
password
.
send_keys
(
PAYPAL_PASSWORD
)
# Prevent the test from advancing before credentials are entered.
wait
=
WebDriverWait
(
self
.
browser
,
2
)
credentials_provided
=
input_provided
(
email
,
password
)
wait
.
until
(
credentials_provided
)
self
.
browser
.
find_element_by_css_selector
(
'button[type="submit"]'
)
.
click
()
self
.
browser
.
switch_to
.
default_content
()
...
...
acceptance_tests/pages/coupons.py
View file @
ed584d91
...
...
@@ -10,6 +10,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from
acceptance_tests.config
import
VERIFIED_COURSE_ID
from
acceptance_tests.constants
import
DEFAULT_END_DATE
,
DEFAULT_START_DATE
from
acceptance_tests.expected_conditions
import
option_selected
from
acceptance_tests.pages.ecommerce
import
EcommerceAppPage
...
...
@@ -21,15 +22,6 @@ def _get_coupon_name(is_discount):
return
prefix
+
suffix
class
verified_option_selected
(
object
):
"""An expectation for checking that the verified option has been selected."""
def
__init__
(
self
,
select
):
self
.
select
=
select
def
__call__
(
self
,
_
):
return
self
.
select
.
first_selected_option
.
text
==
'Verified'
class
BasketPage
(
EcommerceAppPage
):
path
=
'basket'
...
...
@@ -61,7 +53,7 @@ class CouponsCreatePage(EcommerceAppPage):
self
.
q
(
css
=
course_id_input
)
.
fill
(
VERIFIED_COURSE_ID
)
self
.
wait_for_ajax
()
wait
=
WebDriverWait
(
self
.
browser
,
5
)
wait
=
WebDriverWait
(
self
.
browser
,
2
)
verified_option_present
=
EC
.
presence_of_element_located
(
(
By
.
CSS_SELECTOR
,
'select[name="seat_type"] option[value="Verified"]'
)
)
...
...
@@ -74,15 +66,16 @@ class CouponsCreatePage(EcommerceAppPage):
select
=
Select
(
self
.
browser
.
find_element_by_css_selector
(
'select[name="seat_type"]'
))
select
.
select_by_visible_text
(
'Verified'
)
# This prevents the test from advancing before the seat type is selected.
wait
=
WebDriverWait
(
self
.
browser
,
5
)
# Prevent the test from advancing before the seat type is selected.
wait
=
WebDriverWait
(
self
.
browser
,
2
)
verified_option_selected
=
option_selected
(
select
,
'Verified'
)
wait
.
until
(
verified_option_selected
)
if
is_discount
:
select
=
Select
(
self
.
browser
.
find_element_by_css_selector
(
'select[name="code_type"]'
))
select
.
select_by_visible_text
(
'Discount Code'
)
wait
=
WebDriverWait
(
self
.
browser
,
5
)
wait
=
WebDriverWait
(
self
.
browser
,
2
)
benefit_input_present
=
EC
.
presence_of_element_located
((
By
.
CSS_SELECTOR
,
'input[name="benefit_value"]'
))
wait
.
until
(
benefit_input_present
)
...
...
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