def __enter__(self): # More mozwebqa bootstrapping, start the browser, expose some # client attrs on testsetup, navigate to the requested url, # return a Page instance with the current testsetup # This should mimic the behavior of mozwebqa as closely as possible self.testsetup.selenium_client.start() copy_attrs = ( 'selenium', 'timeout', 'default_implicit_wait' ) for attr in copy_attrs: setattr(self.testsetup, attr, getattr(self.testsetup.selenium_client, attr)) self.testsetup.base_url = self.url self.testsetup.selenium.maximize_window() self.testsetup.selenium.get(self.url) # Is it a page or a fixture? if type(self.page_or_fixture) == types.FunctionType: # Function! It's a fixture and we should use it... home_page_logged_in = navigation.home_page_logged_in(self.testsetup) # If you passed in the home_page_logged_in fixture, this will be funny. return self.page_or_fixture(home_page_logged_in) else: # Not a function! It's probably a Page class that we should set up return self.page_or_fixture(self.testsetup)
def test_fixture(mozwebqa, fixture_name): home_pg = navigation.home_page_logged_in(mozwebqa) fixture_pg = getattr(navigation, fixture_name)(home_pg) Assert.true(fixture_pg.is_the_current_page)