class BaseTest: driver = None def setup_class(self): self.driver = webdriver.Chrome( executable_path=ChromeDriverManager().install()) self.login_page = LoginPage(self.driver) self.login_page.open_page() self.dashboard_page = DashboardPage(self.driver) self.login_page.login_to_jira(ValidUser.username, ValidUser.password) assert self.dashboard_page.at_page() self.create_issue_page = CreateIssuePage(self.driver) def teardown_class(self): self.driver.close() def log_full(r): req = r.request """ At this point it is completely built and ready to be fired; it is "prepared". However pay attention at the formatting used in this function because it is programmed to be pretty printed and may differ from the actual request. """ print() print('{}\n{}\n{}\n\n{}'.format( '-----------REQUEST-----------', req.method + ' ' + req.url, '\n'.join('{}: {}'.format(k, v) for k, v in req.headers.items()), req.body, )) print() print('{}\n{}\n{}\n\n{}'.format( '-----------RESPONSE-----------', r.status_code, '\n'.join('{}: {}'.format(k, v) for k, v in r.headers.items()), r.text, )) print()
class TestLogin(BaseTest): def setup_class(self): self.driver = webdriver.Chrome( executable_path=ChromeDriverManager().install()) self.login_page = LoginPage(self.driver) self.dashboard_page = DashboardPage(self.driver) self.create_issue_page = CreateIssuePage(self.driver) @allure.tag("UI") @allure.title("Login with correct username & wrong password") def test_login_correct_username_wrong_password(self): self.login_page.open_page() assert self.login_page.at_page() self.login_page.login_to_jira(ValidUser.username, InvalidUser.password) assert self.login_page.is_error_shown() @allure.tag("UI") @allure.title("Login with wrong username & correct password") def test_login_wrong_username_correct_password(self): self.login_page.open_page() assert self.login_page.at_page() self.login_page.login_to_jira(InvalidUser.username, ValidUser.password) assert self.login_page.is_error_shown() @allure.tag("UI") @allure.title("Login with correct username & correct password") def test_login_correct_username_correct_password(self): self.login_page.open_page() assert self.login_page.at_page() self.login_page.login_to_jira(ValidUser.username, ValidUser.password) assert self.dashboard_page.at_page()