Created
January 17, 2012 02:29
-
-
Save pamelafox/1624190 to your computer and use it in GitHub Desktop.
Python Selenium Base TestCase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import datetime | |
from sys import * | |
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
import login_dom | |
class BaseTests(unittest.TestCase): | |
driver = None | |
waiter = None | |
TIMEOUT = 20 | |
BASE_DOMAIN = 'http://localhost.eatdifferent.com' | |
@classmethod | |
def tearDownClass(cls): | |
return | |
cls.driver.quit() | |
@classmethod | |
def setUpClass(cls): | |
cls.driver = webdriver.Chrome() | |
#cls.driver = webdriver.Firefox() | |
#cls.driver = webdriver.Remote(command_executor='http://192.168.1.81:3001/wd/hub', desired_capabilities={'browserName': 'iphone'}) | |
cls.waiter = WebDriverWait(cls.driver, cls.TIMEOUT) | |
cls.open_page(cls.BASE_DOMAIN + '/not-yet?debug=true&debugmode=fast') | |
@classmethod | |
def open_page(cls, url): | |
if not url.startswith('http'): | |
url = cls.BASE_DOMAIN + url | |
cls.driver.get(url) | |
@classmethod | |
def clear_data(cls): | |
cls.driver.get(cls.BASE_DOMAIN + '/clear-data') | |
print 'Cleared data' | |
@classmethod | |
def clear_log_data(cls): | |
cls.driver.get(cls.BASE_DOMAIN + '/clear-log-data') | |
print 'Cleared log data' | |
def login(self): | |
self.login_dom = login_dom.LoginDom(self.__class__.driver, self.__class__.waiter) | |
self.open('/login') | |
self.login_dom.good_login() | |
def logout(self): | |
self.open('/action/handle-logout') | |
def open(self, path): | |
self.__class__.open_page(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment