Beispiel #1
0
class ExampleTest2(unittest.TestCase):
    """This example shows how to use the page object pattern.
    
    For more information about this pattern, see:
    http://code.google.com/p/webdriver/wiki/PageObjects
    """
    
    def setUp(self):
        self._driver = WebDriver()

    def tearDown(self):
        self._driver.quit()

    def testSearch(self):
        google = GoogleOneBox(self._driver, "http://www.google.com")
        res = google.search_for("cheese")
        self.assertTrue(res.link_contains_match_for("Wikipedia"))
Beispiel #2
0
class FirefoxLauncherTests(unittest.TestCase):
    def testLaunchAndCloseBrowser(self):
        self.webdriver = WebDriver()
        self.webdriver.quit()

    def testDoubleClose(self):
        self.webdriver = WebDriver()
        self.webdriver.close()
        self.webdriver.close()
        self.webdriver.quit()
class WebDriverDriver(BaseDriver):
    backend = 'webdriver'

    def __init__(self, context, selenium=None):
        self.context = context
        self.selenium = selenium

    def start_test(self, url=None):
        self.webdriver = WebDriver()

    def stop_test(self):
        self.webdriver.quit()

    def resolve_element_key(self, context, element_type, element_key):
        if not context:
            return element_key
        return SeleniumElementSelector.element(element_type, element_key)

    def page_open(self, url):
        self.webdriver.get(url)

    def wait_for_page(self, timeout=10000):
        # Does not make sense for WebDriver.
        pass

    def click_element(self, element_selector):
        self.webdriver.find_element_by_xpath(element_selector).click()

    def get_title(self):
        return self.webdriver.get_title()

    def is_element_visible(self, element_selector):
        try:
            element = self.webdriver.find_element_by_xpath(element_selector)
        except NoSuchElementException, e:
            return False
        except StaleElementReferenceException, e:
            return False
Beispiel #4
0
 def testDoubleClose(self):
     self.webdriver = WebDriver()
     self.webdriver.close()
     self.webdriver.close()
     self.webdriver.quit()
Beispiel #5
0
 def testLaunchAndCloseBrowser(self):
     self.webdriver = WebDriver()
     self.webdriver.quit()
 def start_test(self, url=None):
     self.webdriver = WebDriver()
Beispiel #7
0
 def setUp(self):
     self._driver = WebDriver()