diff --git a/payment/tests.py b/payment/tests.py index 78defcff..6ea46fd5 100644 --- a/payment/tests.py +++ b/payment/tests.py @@ -67,30 +67,56 @@ def paySandbox(test, selenium, url, authorize=False): print "PAY SANDBOX" try: + # We need this sleep to make sure the JS engine is finished from the sandbox loging page + time.sleep(20) + selenium.get(url) - login_element = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("loadLogin")) - login_element.click() - - email_element = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("login_email")) + print "Opened URL %s" % url + + try: + # Button is only visible if the login box is NOT open + # If the login box is open, the email/pw fiels are already accessible + login_element = WebDriverWait(selenium, 30).until(lambda d : d.find_element_by_id("loadLogin")) + login_element.click() + + # This sleep is needed for js to slide the buyer login into view. The elements are always in the DOM + # so selenium can find them, but we need them in view to interact + time.sleep(20) + except: + print "Ready for Login" + + email_element = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("login_email")) email_element.click() email_element.send_keys(settings.PAYPAL_BUYER_LOGIN) - password_element = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("login_password")) + password_element = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("login_password")) password_element.click() password_element.send_keys(settings.PAYPAL_BUYER_PASSWORD) - submit_button = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("submitLogin")) + submit_button = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("submitLogin")) submit_button.click() + + # This sleep makes sure js has time to animate out the next page + time.sleep(20) - final_submit = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("submit.x")) + final_submit = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("submit.x")) final_submit.click() - - return_button = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("returnToMerchant")) - return_button.click() + + # This makes sure the processing of the final submit is complete + time.sleep(20) + + # Don't wait too long for this, it isn't really needed. By the time JS has gotten around to + # displaying this element, the redirect has usually occured + try: + return_button = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("returnToMerchant")) + return_button.click() + except: + blah = "blah" except: traceback.print_exc() + print "Tranasction Complete" class PledgeTest(TestCase): diff --git a/selenium/INSTALL b/selenium/INSTALL index f8d8e527..1f3b9e8b 100644 --- a/selenium/INSTALL +++ b/selenium/INSTALL @@ -1,14 +1,13 @@ Instructions to install xvfb + jdk 1) sudo apt-get install openjdk-6-jre-headless -2) sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic +2) sudo apt-get install xfonts-base xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic 3) sudo apt-get install xvfb -4) sudo apt-get install xserver-xorg-core -5) sudo apt-get install firefox -6) sudo cp xvfb /etc/init.d/xvfb -7) sudo chmod 755 /etc/init.d/xvfb -8) sudo cp selenium /etc/init.d/selenium -9) sudo chmod 755 /etc/init.d/selenium +4) sudo apt-get install firefox +5) sudo cp xvfb /etc/init.d/xvfb +6) sudo chmod 755 /etc/init.d/xvfb +7) sudo cp selenium /etc/init.d/selenium +8) sudo chmod 755 /etc/init.d/selenium Instructions to manually restart xvfb + selenium server @@ -17,5 +16,5 @@ Instructions to manually restart xvfb + selenium server Create a link to auto start xvfb+selenium on startup 1) sudo ln -s /etc/init.d/xvfb /etc/rc2.d/S66xvfb -2) sudo ln -d /etc/init.d/selenium /etc/rc2.d/S67selenium +2) sudo ln -s /etc/init.d/selenium /etc/rc2.d/S67selenium diff --git a/selenium/xvfb b/selenium/xvfb index a48bd8f7..8df6c50a 100644 --- a/selenium/xvfb +++ b/selenium/xvfb @@ -5,7 +5,7 @@ fi case "$1" in start) -/usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 & +/usr/bin/Xvfb :99 -ac -screen 0 2048x2048x8 & ;; stop)