add ability to delete fork;

rework BaseTestCase to use 2 drivers and setup\teardown classmethods;
move all preconditions for tests to setup\teardown classmethods.
This commit is contained in:
Churikova Tetiana 2018-02-06 12:58:13 +02:00
parent 417018572e
commit ccf3fcc485
2 changed files with 22 additions and 26 deletions

View File

@ -16,6 +16,3 @@ class BasePageObject(object):
def time_now(self): def time_now(self):
return datetime.now().strftime('%-m%-d%-H%-M%-S') return datetime.now().strftime('%-m%-d%-H%-M%-S')
@property
def current_url(self):
return self.driver.current_url

View File

@ -14,7 +14,7 @@ class BaseTestCase:
sys.stdout = sys.stderr sys.stdout = sys.stderr
print("SauceOnDemandSessionID=%s job-name=%s" % (driver.session_id, print("SauceOnDemandSessionID=%s job-name=%s" % (driver.session_id,
pytest.config.getoption('build'))) pytest.config.getoption('build')))
def return_caps(self): def get_remote_caps(self):
sauce_lab_cap = dict() sauce_lab_cap = dict()
sauce_lab_cap['name'] = test_data.test_name sauce_lab_cap['name'] = test_data.test_name
sauce_lab_cap['build'] = pytest.config.getoption('build') sauce_lab_cap['build'] = pytest.config.getoption('build')
@ -36,9 +36,9 @@ class BaseTestCase:
cls.errors = [] cls.errors = []
cls.environment = pytest.config.getoption('env') cls.environment = pytest.config.getoption('env')
########################################################################################################################################################## ###################################################################################################################
######### Drivers setup ######### Drivers setup
########################################################################################################################################################## ###################################################################################################################
# #
# Dev Chrome options # Dev Chrome options
@ -58,34 +58,33 @@ class BaseTestCase:
# #
cls.executor_sauce_lab = 'http://%s:%s@ondemand.saucelabs.com:80/wd/hub' % ( cls.executor_sauce_lab = 'http://%s:%s@ondemand.saucelabs.com:80/wd/hub' % (
environ.get('SAUCE_USERNAME'), environ.get('SAUCE_ACCESS_KEY')) environ.get('SAUCE_USERNAME'), environ.get('SAUCE_ACCESS_KEY'))
drivers = []
cls.return_caps(cls)
sauce_lab_cap_dev = cls.capabilities_dev.to_capabilities()
cls.capabilities_sauce_lab_dev = sauce_lab_cap_dev
cls.return_caps(cls)
sauce_lab_cap_org = cls.capabilities_org.to_capabilities()
cls.capabilities_sauce_lab_org = sauce_lab_cap_org
if cls.environment == 'local': if cls.environment == 'local':
cls.driver_dev = webdriver.Chrome(chrome_options=cls.capabilities_dev) for caps in cls.capabilities_dev, cls.capabilities_org:
cls.driver_org = webdriver.Chrome(chrome_options=cls.capabilities_org) driver = webdriver.Chrome(chrome_options=caps)
drivers.append(driver)
if cls.environment == 'sauce': if cls.environment == 'sauce':
cls.driver_dev = webdriver.Remote(cls.executor_sauce_lab, for caps in cls.capabilities_dev, cls.capabilities_org:
desired_capabilities=cls.capabilities_sauce_lab_dev) cls.get_remote_caps(cls)
cls.print_sauce_lab_info(cls, cls.driver_dev) new_caps = caps.to_capabilities()
cls.driver_org = webdriver.Remote(cls.executor_sauce_lab, driver = webdriver.Remote(cls.executor_sauce_lab,
desired_capabilities=cls.capabilities_sauce_lab_org) desired_capabilities=new_caps)
cls.print_sauce_lab_info(cls, cls.driver_org) drivers.append(driver)
for driver in cls.driver_dev, cls.driver_org: for driver in drivers:
cls.print_sauce_lab_info(cls, driver)
cls.driver_dev = drivers[0]
cls.driver_org = drivers[1]
for driver in drivers:
driver.implicitly_wait(10) driver.implicitly_wait(10)
########################################################################################################################################################## ###################################################################################################################
######### Actions for each driver before class ######### Actions for each driver before class
########################################################################################################################################################## ###################################################################################################################
######ORG ######ORG
landing = LandingPage(cls.driver_org) landing = LandingPage(cls.driver_org)