class TestLogin: def setup_method(self): self.driver = webdriver.Chrome( executable_path=ChromeDriverManager().install()) self.login_page = LoginPage(self.driver) self.header_page = HeaderPage(self.driver) @allure.title("Create issue UI") @pytest.mark.regression @pytest.mark.P1 @pytest.mark.ui def test_login_to_jira_markers(self): self.login_page.open() with allure.step("at_page"): assert self.login_page.at_page() self.login_page.login_to_jira() with allure.step("at_page"): assert self.header_page.at_page() @allure.title("Test to be skipped") @pytest.mark.feature @pytest.mark.skip( reason="NMB-12222 User authorization is blocked by advertisement") def test_to_be_skipped(self): # TODO: implement this test pass @allure.title("Unstable test") @pytest.mark.flaky(reruns=3, reruns_delay=1) def test_unstable(self): assert random.randint(1, 2) == 2 def teardown_method(self): self.driver.close()
class TestLogin: def test_login_to_jira_page_object(self): self.login_page = LoginPage(self.driver) self.header_page = HeaderPage(self.driver) self.login_page.open() assert self.login_page.at_page() self.login_page.login_to_jira() assert self.header_page.at_page()
class TestLogin: def setup_method(self): self.driver = webdriver.Chrome( executable_path=ChromeDriverManager().install()) self.login_page = LoginPage(self.driver) self.header_page = HeaderPage(self.driver) def test_login_to_jira_page_object(self): self.login_page.open() assert self.login_page.at_page() self.login_page.login_to_jira() assert self.header_page.at_page() def teardown_method(self): self.driver.close()
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()