Commit a1b8cdf0 by Michael Frey

Coupon Acceptance Tests

parent 3958b4d5
...@@ -5,11 +5,10 @@ def str2bool(s): ...@@ -5,11 +5,10 @@ def str2bool(s):
s = unicode(s) s = unicode(s)
return s.lower() in (u'yes', u'true', u't', u'1') return s.lower() in (u'yes', u'true', u't', u'1')
# GENERAL CONFIGURATION # GENERAL CONFIGURATION
ACCESS_TOKEN = os.environ.get('ACCESS_TOKEN') ACCESS_TOKEN = os.environ.get('ACCESS_TOKEN')
ENABLE_OAUTH2_TESTS = str2bool(os.environ.get('ENABLE_OAUTH2_TESTS', True)) ENABLE_OAUTH2_TESTS = str2bool(os.environ.get('ENABLE_OAUTH2_TESTS', True))
HONOR_COURSE_ID = os.environ.get('HONOR_COURSE_ID', 'edX/DemoX/Demo_Course') HONOR_COURSE_ID = os.environ.get('HONOR_COURSE_ID', 'course-v1:edX+DemoX+Demo_Course')
VERIFIED_COURSE_ID = os.environ.get('VERIFIED_COURSE_ID', 'course-v1:BerkeleyX+ColWri.3.6x+3T2015') VERIFIED_COURSE_ID = os.environ.get('VERIFIED_COURSE_ID', 'course-v1:BerkeleyX+ColWri.3.6x+3T2015')
PROFESSIONAL_COURSE_ID = os.environ.get('PROFESSIONAL_COURSE_ID', 'course-v1:UBCx+Marketing5501x+2T2015') PROFESSIONAL_COURSE_ID = os.environ.get('PROFESSIONAL_COURSE_ID', 'course-v1:UBCx+Marketing5501x+2T2015')
......
from datetime import date
# cybersource data
CYBERSOURCE_DATA1 = {
'country': 'US',
'state': 'MA',
'line1': '141 Portland Ave.',
'line2': '9th Floor',
'city': 'Cambridge',
'postal_code': '02141',
}
CYBERSOURCE_DATA2 = {
'country': 'FR',
'state': None,
'line1': 'Champ de Mars',
'line2': '5 Avenue Anatole',
'city': 'Paris',
'postal_code': '75007',
}
DEFAULT_START_DATE = date(2015, 1, 1)
DEFAULT_END_DATE = date(2050, 1, 1)
...@@ -3,6 +3,10 @@ import uuid ...@@ -3,6 +3,10 @@ import uuid
from ecommerce_api_client.client import EcommerceApiClient from ecommerce_api_client.client import EcommerceApiClient
import requests import requests
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait
from acceptance_tests.api import EnrollmentApiClient from acceptance_tests.api import EnrollmentApiClient
from acceptance_tests.config import ( from acceptance_tests.config import (
...@@ -17,6 +21,8 @@ from acceptance_tests.config import ( ...@@ -17,6 +21,8 @@ from acceptance_tests.config import (
LMS_USERNAME, LMS_USERNAME,
ECOMMERCE_API_TOKEN, ECOMMERCE_API_TOKEN,
MAX_COMPLETION_RETRIES, MAX_COMPLETION_RETRIES,
PAYPAL_PASSWORD,
PAYPAL_EMAIL
) )
from acceptance_tests.pages import LMSLoginPage, LMSDashboardPage, LMSRegistrationPage from acceptance_tests.pages import LMSLoginPage, LMSDashboardPage, LMSRegistrationPage
...@@ -163,3 +169,93 @@ class UnenrollmentMixin(object): ...@@ -163,3 +169,93 @@ class UnenrollmentMixin(object):
# Unenroll # Unenroll
unenroll_link.click() unenroll_link.click()
self.browser.find_element_by_css_selector('#unenroll_form input[name=submit]').click() self.browser.find_element_by_css_selector('#unenroll_form input[name=submit]').click()
class PaymentMixin(object):
def checkout_with_paypal(self):
""" Completes the checkout process via PayPal. """
# Click the payment button
self.browser.find_element_by_css_selector('#paypal').click()
# Wait for form to load
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.ID, 'loginFields')))
# Log into PayPal
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)
self.browser.find_element_by_css_selector('input[type="submit"]').click()
# Wait for the checkout form to load, then submit it.
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.ID, 'confirmButtonTop')))
self.browser.find_element_by_css_selector('input#confirmButtonTop').click()
def checkout_with_cybersource(self, address):
""" Completes the checkout process via CyberSource. """
# Click the payment button
self.browser.find_element_by_css_selector('#cybersource').click()
self._dismiss_alert()
# Wait for form to load
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.ID, 'billing_details')))
# Select the credit card type (Visa) first since it triggers the display of additional fields
self.browser.find_element_by_css_selector('#card_type_001').click() # Visa
# Select the appropriate <option> elements
select_fields = (
('#bill_to_address_country', address['country']),
('#bill_to_address_state_us_ca', address['state']),
('#card_expiry_month', '01'),
('#card_expiry_year', '2020')
)
for selector, value in select_fields:
if value:
select = Select(self.browser.find_element_by_css_selector(selector))
select.select_by_value(value)
# Fill in the text fields
billing_information = {
'bill_to_forename': 'Ed',
'bill_to_surname': 'Xavier',
'bill_to_address_line1': address['line1'],
'bill_to_address_line2': address['line2'],
'bill_to_address_city': address['city'],
'bill_to_address_postal_code': address['postal_code'],
'bill_to_email': 'edx@example.com',
'card_number': '4111111111111111',
'card_cvn': '1234'
}
for field, value in billing_information.items():
self.browser.find_element_by_css_selector('#' + field).send_keys(value)
# Click the payment button
self.browser.find_element_by_css_selector('input[type=submit]').click()
self._dismiss_alert()
def assert_receipt_page_loads(self):
""" Verifies the receipt page loaded in the browser. """
# Wait for the payment processor response to be processed, and the receipt page updated.
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'content-main')))
# Verify we reach the receipt page.
self.assertIn('receipt', self.browser.title.lower())
# Check the content of the page
cells = self.browser.find_elements_by_css_selector('table.report-receipt tbody td')
self.assertGreater(len(cells), 0)
order = self.ecommerce_api_client.orders.get()['results'][0]
line = order['lines'][0]
expected = [
order['number'],
line['description'],
order['date_placed'],
'{amount} ({currency})'.format(amount=line['line_price_excl_tax'], currency=order['currency'])
]
actual = [cell.text for cell in cells]
self.assertListEqual(actual, expected)
# pylint: disable=wildcard-import # pylint: disable=wildcard-import
from acceptance_tests.pages.coupons import *
from acceptance_tests.pages.ecommerce import * from acceptance_tests.pages.ecommerce import *
from acceptance_tests.pages.lms import * from acceptance_tests.pages.lms import *
from acceptance_tests.pages.marketing import * from acceptance_tests.pages.marketing import *
from bok_choy.javascript import wait_for_js
from factory.fuzzy import FuzzyText
from acceptance_tests.config import VERIFIED_COURSE_ID
from acceptance_tests.constants import DEFAULT_END_DATE, DEFAULT_START_DATE
from acceptance_tests.pages.ecommerce import EcommerceAppPage
def _get_coupon_name(is_discount):
""" Returns an appropriate coupon name. """
prefix = 'test-discount-code-' if is_discount else 'test-enrollment-code-'
return FuzzyText(length=3, prefix=prefix).fuzz()
class BasketPage(EcommerceAppPage):
path = 'basket'
def is_browser_on_page(self):
return self.browser.title.startswith('Basket')
class CouponsCreatePage(EcommerceAppPage):
path = 'coupons/new'
def is_browser_on_page(self):
return self.q(css='form.coupon-form-view').visible
@wait_for_js
def fill_create_coupon_form(self, is_discount):
""" Fills the coupon form with test data and creates the coupon.
Args:
is_discount(bool): Indicates if the code that's going to be created
should be a discount or enrollment coupon code.
Returns:
coupon_name(str): Fuzzied name of the coupon that has been created.
"""
course_id_input = 'input[name="course_id"]'
coupon_name = _get_coupon_name(is_discount)
self.q(css='input[name="title"]').fill(coupon_name)
self.q(css=course_id_input).fill(VERIFIED_COURSE_ID)
self.wait_for_ajax()
self.wait_for_element_presence(
'select[name="seat_type"] option[value="Verified"]',
'Seat Type Drop-Down List is Present'
)
self.q(css="input[name='start_date']").fill(str(DEFAULT_START_DATE))
self.q(css="input[name='end_date']").fill(str(DEFAULT_END_DATE))
self.q(css="input[name='client_username']").fill('Test Client')
self.q(css='select[name="seat_type"] option[value="Verified"]').first.click()
if is_discount:
self.q(css='select[name="code_type"] option[value="discount"]').first.click()
self.wait_for_element_presence('input[name="benefit_value"]', 'Benefit Value Input is Present')
self.q(css="input[name='benefit_value']").fill('50')
self.q(css="div.form-actions > button.btn").click()
self.wait_for_ajax()
return coupon_name
@wait_for_js
def update_coupon_date(self, start_date=DEFAULT_START_DATE, end_date=DEFAULT_END_DATE):
self.q(css="input[name='start_date']").fill(str(start_date))
self.q(css="input[name='end_date']").fill(str(end_date))
self.q(css="div.form-actions > button.btn").click()
self.wait_for_ajax()
class CouponsDetailsPage(EcommerceAppPage):
def is_browser_on_page(self):
return self.browser.title.endswith('- View Coupon')
@wait_for_js
def get_redeem_url(self):
return self.q(css='table#vouchersTable tbody tr td')[1].text
@wait_for_js
def go_to_edit_coupon_form_page(self):
self.browser.find_element_by_id('CouponEdit').click()
# self.q(css='div.coupon-detail-view div.pull-right a.btn.btn-primary.btn-small').first.click()
self.wait_for_ajax()
class CouponsListPage(EcommerceAppPage):
path = 'coupons'
def is_browser_on_page(self):
return self.browser.title.startswith('Coupon Codes')
def create_new_coupon(self):
self.browser.find_element_by_id('CreateCoupon').click()
self.wait_for_ajax()
@wait_for_js
def go_to_coupon_details_page(self, coupon_name):
self.q(css='input[type="search"]').fill(coupon_name)
self.wait_for_ajax()
# self.q(css='table#couponTable tbody tr td a').first.click()
self.browser.find_element_by_id('couponTable').first.click()
self.wait_for_ajax()
class RedeemVoucherPage(EcommerceAppPage):
def is_browser_on_page(self):
return self.browser.title.startswith('Redeem')
@wait_for_js
def proceed_to_enrollment(self):
""" Enroll user to a course and redeem voucher code in the process """
self.browser.find_element_by_id('RedeemEnrollment').click()
self.wait_for_ajax()
@wait_for_js
def proceed_to_checkout(self):
""" Purchase a course and redeem voucher code in the process """
self.browser.find_element_by_id('PurchaseCertificate').click()
self.wait_for_ajax()
from datetime import date
from bok_choy.web_app_test import WebAppTest
from acceptance_tests.constants import DEFAULT_END_DATE, DEFAULT_START_DATE
from acceptance_tests.mixins import LogistrationMixin
from acceptance_tests.pages import CouponsCreatePage, CouponsDetailsPage, CouponsListPage
class CouponAdministrationTests(LogistrationMixin, WebAppTest):
def setUp(self):
""" Instantiate the page objects. """
super(CouponAdministrationTests, self).setUp()
self.coupons_create_edit_page = CouponsCreatePage(self.browser)
self.coupons_details_page = CouponsDetailsPage(self.browser)
self.coupons_list_page = CouponsListPage(self.browser)
self.login_with_lms()
def create_coupon(self):
""" Create a coupon via UI. """
# Verify we reach the coupons list page.
self.coupons_list_page.visit()
self.assertTrue(self.coupons_list_page.is_browser_on_page())
self.coupons_list_page.create_new_coupon()
# Verify we reach the coupons create / edit page.
self.assertTrue(self.coupons_create_edit_page.is_browser_on_page())
self.coupons_create_edit_page.fill_create_coupon_form(is_discount=False)
# Verify we reach the coupons details page.
self.assertTrue(self.coupons_details_page.is_browser_on_page())
def assert_coupon_dates(self, expected_start_date, expected_end_date):
""" Assert the start/end dates displayed to the user match the expected dates. """
start_date = self.browser.find_elements_by_css_selector(
'div.coupon-detail-view div.start-date-info div.value'
)[0].text
end_date = self.browser.find_elements_by_css_selector(
'div.coupon-detail-view div.end-date-info div.value'
)[0].text
self.assertEqual(start_date, expected_start_date.strftime('%m/%d/%Y %I:%M %p'))
self.assertEqual(end_date, expected_end_date.strftime('%m/%d/%Y %I:%M %p'))
def test_create_coupon(self):
""" Test creating a new coupon. """
self.create_coupon()
def test_update_coupon_dates(self):
""" Test updating the dates on a coupon. """
self.create_coupon()
self.assert_coupon_dates(DEFAULT_START_DATE, DEFAULT_END_DATE)
self.coupons_details_page.go_to_edit_coupon_form_page()
self.assertTrue(self.coupons_create_edit_page.is_browser_on_page())
future_start_date = date(3000, 1, 1)
future_end_date = date(4000, 1, 1)
self.coupons_create_edit_page.update_coupon_date(start_date=future_start_date, end_date=future_end_date)
self.assertTrue(self.coupons_details_page.is_browser_on_page())
self.assert_coupon_dates(future_start_date, future_end_date)
from unittest import skipUnless
import ddt
from bok_choy.web_app_test import WebAppTest
from acceptance_tests.config import VERIFIED_COURSE_ID, ENABLE_CYBERSOURCE_TESTS
from acceptance_tests.mixins import (EcommerceApiMixin, EnrollmentApiMixin,
LogistrationMixin, UnenrollmentMixin, PaymentMixin)
from acceptance_tests.constants import CYBERSOURCE_DATA1, CYBERSOURCE_DATA2
from acceptance_tests.pages import (BasketPage, CouponsCreatePage,
CouponsDetailsPage, CouponsListPage,
DashboardHomePage, RedeemVoucherPage)
class CouponCheckoutTests(UnenrollmentMixin, EcommerceApiMixin, EnrollmentApiMixin, LogistrationMixin,
PaymentMixin, WebAppTest):
def setUp(self):
""" Instantiate the page objects. """
super(CouponCheckoutTests, self).setUp()
self.app_login_page = DashboardHomePage(self.browser)
self.basket_page = BasketPage(self.browser)
self.coupons_create_edit_page = CouponsCreatePage(self.browser)
self.coupons_list_page = CouponsListPage(self.browser)
self.coupons_details_page = CouponsDetailsPage(self.browser)
self.redeem_voucher_page = RedeemVoucherPage(self.browser)
self.course_id = VERIFIED_COURSE_ID
self.username, self.password, self.email = self.get_lms_user()
self.login_with_lms()
def start_redeem_flow(self, is_discount=False):
""" Start redemption flow by creating a coupon via the UI and then accepting the offer """
self.prepare_coupon(is_discount)
# Get the redeem URL for the coupon's detail page and go to it.
redeem_url = self.coupons_details_page.get_redeem_url()
self.browser.get(redeem_url)
self.assertTrue(self.redeem_voucher_page.is_browser_on_page())
if is_discount:
self.redeem_voucher_page.proceed_to_checkout()
else:
self.redeem_voucher_page.proceed_to_enrollment()
def prepare_coupon(self, is_discount=False):
""" Create a test coupon and open its details page. """
self.app_login_page.visit()
self.assertTrue(self.app_login_page.is_browser_on_page())
self.coupons_list_page.visit().create_new_coupon()
self.coupons_create_edit_page.fill_create_coupon_form(is_discount)
self.assertTrue(self.coupons_details_page.is_browser_on_page())
def test_enrollment_code_redemption(self):
""" Test redeeming an enrollment code enrolls the learner. """
self.start_redeem_flow()
self.assert_order_created_and_completed()
self.assert_user_enrolled(self.username, self.course_id, mode='verified')
def test_discount_checkout_with_paypal(self):
""" Test redemption of discount code and purchase of course via PayPal """
self.start_redeem_flow(is_discount=True)
self.assertTrue(self.basket_page.is_browser_on_page())
self.checkout_with_paypal()
self.assert_receipt_page_loads()
self.assert_order_created_and_completed()
self.assert_user_enrolled(self.username, self.course_id, 'verified')
@skipUnless(ENABLE_CYBERSOURCE_TESTS, 'CyberSource tests are not enabled.')
@ddt.data(CYBERSOURCE_DATA1, CYBERSOURCE_DATA2)
def test_discount_checkout_with_cybersource(self, address):
""" Test redemption of discount code and purchase of course via Cybersource """
self.start_redeem_flow(is_discount=True)
self.assertTrue(self.basket_page.is_browser_on_page())
self.checkout_with_cybersource(address)
self.assert_receipt_page_loads()
self.assert_order_created_and_completed()
self.assert_user_enrolled(self.username, self.course_id, 'verified')
...@@ -5,20 +5,19 @@ import ddt ...@@ -5,20 +5,19 @@ import ddt
from selenium.common.exceptions import TimeoutException from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from acceptance_tests.config import ( from acceptance_tests.config import (VERIFIED_COURSE_ID, ENABLE_MARKETING_SITE, VERIFIED_COURSE_SLUG,
VERIFIED_COURSE_ID, ENABLE_MARKETING_SITE, VERIFIED_COURSE_SLUG, LMS_HTTPS, PAYPAL_PASSWORD, PAYPAL_EMAIL, LMS_HTTPS, PAYPAL_PASSWORD, PAYPAL_EMAIL, ENABLE_CYBERSOURCE_TESTS)
ENABLE_CYBERSOURCE_TESTS from acceptance_tests.constants import CYBERSOURCE_DATA1, CYBERSOURCE_DATA2
) from acceptance_tests.mixins import (LogistrationMixin, EnrollmentApiMixin, EcommerceApiMixin,
from acceptance_tests.mixins import LogistrationMixin, EnrollmentApiMixin, EcommerceApiMixin, UnenrollmentMixin PaymentMixin, UnenrollmentMixin)
from acceptance_tests.pages import LMSCourseModePage, MarketingCourseAboutPage from acceptance_tests.pages import LMSCourseModePage, MarketingCourseAboutPage
@ddt.ddt @ddt.ddt
class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, EnrollmentApiMixin, LogistrationMixin, class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, EnrollmentApiMixin, LogistrationMixin,
WebAppTest): PaymentMixin, WebAppTest):
def setUp(self): def setUp(self):
super(VerifiedCertificatePaymentTests, self).setUp() super(VerifiedCertificatePaymentTests, self).setUp()
self.course_id = VERIFIED_COURSE_ID self.course_id = VERIFIED_COURSE_ID
...@@ -48,29 +47,6 @@ class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, Enro ...@@ -48,29 +47,6 @@ class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, Enro
# the browser to the payment selection page. # the browser to the payment selection page.
self.browser.find_element_by_css_selector('input[name=verified_mode]').click() self.browser.find_element_by_css_selector('input[name=verified_mode]').click()
def assert_receipt_page_loads(self):
""" Verifies the receipt page loaded in the browser. """
# Wait for the payment processor response to be processed, and the receipt page updated.
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'content-main')))
# Verify we reach the receipt page.
self.assertIn('receipt', self.browser.title.lower())
# Check the content of the page
cells = self.browser.find_elements_by_css_selector('table.report-receipt tbody td')
self.assertGreater(len(cells), 0)
order = self.ecommerce_api_client.orders.get()['results'][0]
line = order['lines'][0]
expected = [
order['number'],
line['description'],
order['date_placed'],
'{amount} ({currency})'.format(amount=line['line_price_excl_tax'], currency=order['currency'])
]
actual = [cell.text for cell in cells]
self.assertListEqual(actual, expected)
def _dismiss_alert(self): def _dismiss_alert(self):
""" """
If we are testing locally with a non-HTTPS LMS instance, a security alert may appear when transitioning to If we are testing locally with a non-HTTPS LMS instance, a security alert may appear when transitioning to
...@@ -83,99 +59,17 @@ class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, Enro ...@@ -83,99 +59,17 @@ class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, Enro
except TimeoutException: except TimeoutException:
pass pass
def _checkout_with_cybersource(self, address):
""" Completes the checkout process via CyberSource. """
# Click the payment button
self.browser.find_element_by_css_selector('#cybersource').click()
self._dismiss_alert()
# Wait for form to load
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.ID, 'billing_details')))
# Select the credit card type (Visa) first since it triggers the display of additional fields
self.browser.find_element_by_css_selector('#card_type_001').click() # Visa
# Select the appropriate <option> elements
select_fields = (
('#bill_to_address_country', address['country']),
('#bill_to_address_state_us_ca', address['state']),
('#card_expiry_month', '01'),
('#card_expiry_year', '2020')
)
for selector, value in select_fields:
if value:
select = Select(self.browser.find_element_by_css_selector(selector))
select.select_by_value(value)
# Fill in the text fields
billing_information = {
'bill_to_forename': 'Ed',
'bill_to_surname': 'Xavier',
'bill_to_address_line1': address['line1'],
'bill_to_address_line2': address['line2'],
'bill_to_address_city': address['city'],
'bill_to_address_postal_code': address['postal_code'],
'bill_to_email': 'edx@example.com',
'card_number': '4111111111111111',
'card_cvn': '1234'
}
for field, value in billing_information.items():
self.browser.find_element_by_css_selector('#' + field).send_keys(value)
# Click the payment button
self.browser.find_element_by_css_selector('input[type=submit]').click()
self._dismiss_alert()
@skipUnless(ENABLE_CYBERSOURCE_TESTS, 'CyberSource tests are not enabled.') @skipUnless(ENABLE_CYBERSOURCE_TESTS, 'CyberSource tests are not enabled.')
@ddt.data( @ddt.data(CYBERSOURCE_DATA1, CYBERSOURCE_DATA2)
{
'country': 'US',
'state': 'MA',
'line1': '141 Portland Ave.',
'line2': '9th Floor',
'city': 'Cambridge',
'postal_code': '02141',
},
{
'country': 'FR',
'state': None,
'line1': 'Champ de Mars',
'line2': '5 Avenue Anatole',
'city': 'Paris',
'postal_code': '75007',
}
)
def test_cybersource(self, address): def test_cybersource(self, address):
""" Test checkout with CyberSource. """ """ Test checkout with CyberSource. """
self._start_checkout() self._start_checkout()
self._checkout_with_cybersource(address) self.checkout_with_cybersource(address)
self.assert_receipt_page_loads() self.assert_receipt_page_loads()
self.assert_order_created_and_completed() self.assert_order_created_and_completed()
self.assert_user_enrolled(self.username, self.course_id, 'verified') self.assert_user_enrolled(self.username, self.course_id, 'verified')
def _checkout_with_paypal(self):
""" Completes the checkout process via PayPal. """
# Click the payment button
self.browser.find_element_by_css_selector('#paypal').click()
# Wait for form to load
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.ID, 'loginFields')))
# Log into PayPal
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)
self.browser.find_element_by_css_selector('input[type="submit"]').click()
# Wait for the checkout form to load, then submit it.
WebDriverWait(self.browser, 10).until(EC.presence_of_element_located((By.ID, 'confirmButtonTop')))
self.browser.find_element_by_css_selector('input#confirmButtonTop').click()
def test_paypal(self): def test_paypal(self):
""" Test checkout with PayPal. """ """ Test checkout with PayPal. """
...@@ -183,7 +77,7 @@ class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, Enro ...@@ -183,7 +77,7 @@ class VerifiedCertificatePaymentTests(UnenrollmentMixin, EcommerceApiMixin, Enro
self.fail('No PayPal credentials supplied!') self.fail('No PayPal credentials supplied!')
self._start_checkout() self._start_checkout()
self._checkout_with_paypal() self.checkout_with_paypal()
self.assert_receipt_page_loads() self.assert_receipt_page_loads()
self.assert_order_created_and_completed() self.assert_order_created_and_completed()
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<span class="coupon-title"><%= coupon['title'] %></span> <span class="coupon-title"><%= coupon['title'] %></span>
<div class="pull-right"> <div class="pull-right">
<a class="btn btn-primary btn-small" href="/coupons/<%= coupon['id'] %>/edit/"> <a class="btn btn-primary btn-small" href="/coupons/<%= coupon['id'] %>/edit/" id="CouponEdit">
<%= gettext('Edit Coupon') %> <%= gettext('Edit Coupon') %>
</a> </a>
</div> </div>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<h1 class="hd-1 emphasized"> <h1 class="hd-1 emphasized">
<%- gettext('Coupon Codes') %> <%- gettext('Coupon Codes') %>
<div class="pull-right"> <div class="pull-right">
<a href="/coupons/new/" class="btn btn-primary btn-small"><%- gettext('Create Coupon') %></a> <a href="/coupons/new/" class="btn btn-primary btn-small" id="CreateCoupon"><%- gettext('Create Coupon') %></a>
</div> </div>
</h1> </h1>
</div> </div>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div class="data-row total-row">{% trans "Total:" %} <div class="data-row total-row">{% trans "Total:" %}
<div class="text-right">${{new_price}}</div> <div class="text-right">${{new_price}}</div>
</div> </div>
<a href="{% url 'coupons:redeem' %}?code={{ code }}" class="btn btn-success btn-purchase">{% trans "Purchase Certificate" %}</a> <a href="{% url 'coupons:redeem' %}?code={{ code }}" id="PurchaseCertificate" class="btn btn-success btn-purchase">{% trans "Purchase Certificate" %}</a>
{% if verified %} {% if verified %}
<div class="verification-note"> <div class="verification-note">
{% blocktrans with verification_deadline=verification_deadline|date:"d M Y" %} {% blocktrans with verification_deadline=verification_deadline|date:"d M Y" %}
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<p> <p>
<b class="total-price">{% trans "Total: $0" %}</b> <b class="total-price">{% trans "Total: $0" %}</b>
</p> </p>
<a href="{% url 'coupons:redeem' %}?code={{ code }}" class="btn btn-primary">{% trans "Enroll and Redeem Code" %}</a> <a href="{% url 'coupons:redeem' %}?code={{ code }}" id="RedeemEnrollment" class="btn btn-primary">{% trans "Enroll and Redeem Code" %}</a>
</div> </div>
{% if verified %} {% if verified %}
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
<div class="row"> <div class="row">
<div class="payment-buttons col-sm-3" data-basket-id="{{ basket.id }}"> <div class="payment-buttons col-sm-3" data-basket-id="{{ basket.id }}">
{% for processor in payment_processors %} {% for processor in payment_processors %}
<button class="btn btn-primary payment-button" value="{{ processor.NAME|lower }}"> <button class="btn btn-primary payment-button" value="{{ processor.NAME|lower }}" id="{{ processor.NAME|lower }}">
{% if processor.NAME == 'cybersource' %} {% if processor.NAME == 'cybersource' %}
{% trans "Checkout" %} {% trans "Checkout" %}
{% elif processor.NAME == 'paypal' %} {% elif processor.NAME == 'paypal' %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment