Commit ed584d91 by Renzo Lucioni

Tune PayPal acceptance tests

Also reduce coupon creation wait times.
parent 2261bfdc
"""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])
......@@ -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()
......
......@@ -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)
......
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