"""Unit test module for Selenium testing"""
from selenium import webdriver

from flask.ext.testing import LiveServerTestCase

from tests import TestCase
from pages import LoginPage


class TestUI(TestCase, LiveServerTestCase):
    """Test class for UI integration/workflow testing"""

    def setUp(self):
        """Reset all tables before testing."""

        super(TestUI, self).setUp()

        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(60)
        self.driver.root_uri = self.get_server_url()

    def tearDown(self):
        """Clean db session, drop all tables."""

        self.driver.quit()

        super(TestUI, self).tearDown()

    def test_login_page(self):
        """Ensure login page loads successfully"""

        page = LoginPage(self.driver)
        page.get("/user/sign-in")

        self.assertNotIn("Uh-oh", page.w.find_element_by_tag_name("body").text)

    def test_login_form_facebook_exists(self):
        """Ensure Facebook button present on login form"""

        page = LoginPage(self.driver)
        page.get("/user/sign-in")

        self.assertIsNotNone(page.facebook_button)

@@ -37,16 +37,26 @@
 ting%22%22%22%0A
+import os%0A
 from sel
@@ -390,24 +390,722 @@
 f).setUp()%0A%0A
+        if %22SAUCE_USERNAME%22 in os.environ and %22SAUCE_ACCESS_KEY%22 in os.environ:%0A%0A            capabilities = %7B%0A                %22tunnel-identifier%22: os.environ%5B%22TRAVIS_JOB_NUMBER%22%5D,%0A                %22build%22: os.environ%5B%22TRAVIS_BUILD_NUMBER%22%5D,%0A                %22tags%22: %5Bos.environ%5B%22TRAVIS_PYTHON_VERSION%22%5D, %22CI%22%5D,%0A            %7D%0A            url = %22http://%7Busername%7D:%7Baccess_key%7D@localhost:4445/wd/hub%22.format(%0A                username=os.environ%5B%22SAUCE_USERNAME%22%5D,%0A                access_key=os.environ%5B%22SAUCE_ACCESS_KEY%22%5D,%0A            )%0A%0A            self.driver = webdriver.Remote(%0A                desired_capabilities=capabilities,%0A                command_executor=url%0A            )%0A%0A        else:%0A    
         self
@@ -1134,16 +1134,17 @@
 refox()%0A
+%0A
         

Use Sauce Labs for selenium testing when available