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
4631f9c0
Commit
4631f9c0
authored
Apr 23, 2018
by
raeeschachar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added paypal test
parent
c125d858
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
25 deletions
+51
-25
e2e/test_payment.py
+51
-25
No files found.
e2e/test_payment.py
View file @
4631f9c0
...
...
@@ -9,7 +9,7 @@ from selenium.webdriver.support.wait import WebDriverWait
from
e2e.api
import
DiscoveryApi
,
EcommerceApi
,
EnrollmentApi
from
e2e.config
import
LMS_USERNAME
,
PAYPAL_EMAIL
,
PAYPAL_PASSWORD
from
e2e.helpers
import
EcommerceHelpers
from
e2e.helpers
import
EcommerceHelpers
,
LmsHelpers
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -60,30 +60,10 @@ class TestSeatPayment(object):
# Click the payment button
selenium
.
find_element_by_id
(
'payment-button'
)
.
click
()
def
checkout_with_paypal
(
self
,
selenium
):
selenium
.
find_element_by_css_selector
(
'button.payment-button[data-processor-name=paypal]'
)
.
click
()
# Wait for login form to load. PayPal's test environment is slow.
login_iframe
=
selenium
.
find_element_by_css_selector
(
'#injectedUnifiedLogin > iframe'
)
selenium
.
switch_to
.
frame
(
login_iframe
)
# Log into PayPal
email
=
selenium
.
find_element_by_id
(
'email'
)
password
=
selenium
.
find_element_by_id
(
'password'
)
email
.
send_keys
(
PAYPAL_EMAIL
)
password
.
send_keys
(
PAYPAL_PASSWORD
)
selenium
.
find_element_by_id
(
'btnLogin'
)
.
click
()
selenium
.
switch_to
.
default_content
()
# Wait for the checkout form to load, and for the loading spinner to disappear.
wait
=
WebDriverWait
(
selenium
,
10
)
spinner_invisibility
=
EC
.
invisibility_of_element_located
((
By
.
ID
,
'spinner'
))
wait
.
until
(
spinner_invisibility
)
selenium
.
find_element_by_id
(
'confirmButtonTop'
)
.
click
()
def
assert_browser_on_receipt_page
(
self
,
selenium
):
selenium
.
find_element_by_id
(
'receipt-container'
)
WebDriverWait
(
selenium
,
20
)
.
until
(
EC
.
visibility_of_element_located
((
By
.
ID
,
'receipt-container'
))
)
def
assert_user_enrolled_in_course_run
(
self
,
username
,
course_run_key
,
seat_type
=
'verified'
,
attempts
=
5
):
""" Asserts the given user has an *active* enrollment for the given course run and seat type/mode.
...
...
@@ -119,7 +99,11 @@ class TestSeatPayment(object):
def
add_item_to_basket
(
self
,
selenium
,
sku
):
# Add the item to the basket and start the checkout process
selenium
.
get
(
EcommerceHelpers
.
build_url
(
'/basket/add/?sku='
+
sku
))
assert
selenium
.
find_element_by_css_selector
(
'.basket-client-side'
)
.
is_displayed
()
# Wait till the selector is visible
WebDriverWait
(
selenium
,
20
)
.
until
(
EC
.
visibility_of_element_located
((
By
.
CSS_SELECTOR
,
".basket-client-side"
))
)
def
refund_orders_for_course_run
(
self
,
course_run_id
):
api
=
EcommerceApi
()
...
...
@@ -128,6 +112,7 @@ class TestSeatPayment(object):
for
refund_id
in
refund_ids
:
api
.
process_refund
(
refund_id
,
'approve'
)
return
True
def
get_verified_seat
(
self
,
course_run
):
verified_seat
=
None
...
...
@@ -136,3 +121,44 @@ class TestSeatPayment(object):
verified_seat
=
seat
break
return
verified_seat
def
checkout_with_paypal
(
self
,
selenium
):
selenium
.
find_element_by_css_selector
(
'.payment-processor-paypal'
)
.
click
()
# Log into PayPal
paypal_email
=
WebDriverWait
(
selenium
,
10
)
.
until
(
EC
.
visibility_of_element_located
((
By
.
ID
,
'email'
))
)
paypal_email
.
send_keys
(
PAYPAL_EMAIL
)
selenium
.
find_element_by_id
(
'btnNext'
)
.
click
()
password
=
WebDriverWait
(
selenium
,
10
)
.
until
(
EC
.
visibility_of_element_located
((
By
.
ID
,
'password'
))
)
password
.
send_keys
(
PAYPAL_PASSWORD
)
selenium
.
find_element_by_id
(
'btnLogin'
)
.
click
()
# Wait for Spinner invisibility as paypal loading is slow
WebDriverWait
(
selenium
,
20
)
.
until
(
EC
.
invisibility_of_element_located
((
By
.
ID
,
'preloaderSpinner'
))
)
paypal_continue
=
WebDriverWait
(
selenium
,
10
)
.
until
(
EC
.
visibility_of_element_located
((
By
.
ID
,
'confirmButtonTop'
))
)
paypal_continue
.
click
()
def
test_verified_seat_payment_with_paypal
(
self
,
selenium
):
""" Validates users can add a verified seat to the cart and checkout with PayPal. """
LmsHelpers
.
login
(
selenium
)
# Get the course run we want to purchase
course_run
=
self
.
get_verified_course_run
()
verified_seat
=
self
.
get_verified_seat
(
course_run
)
self
.
add_item_to_basket
(
selenium
,
verified_seat
[
'sku'
])
self
.
checkout_with_paypal
(
selenium
)
self
.
assert_browser_on_receipt_page
(
selenium
)
course_run_key
=
course_run
[
'key'
]
self
.
assert_user_enrolled_in_course_run
(
LMS_USERNAME
,
course_run_key
)
self
.
refund_orders_for_course_run
(
course_run_key
)
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