class TestLogin: @pytest.mark.parametrize("login, passwd, rez", [ ("admin", "changeme", "please try again."), ("admin", "wrongPass", "please try again"), ("wrongLogin", "changeme", "System Dashboard"), ] ) def test_login_to_jira_page_object(self, login, passwd, rez): 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.enter_name(login) self.login_page.enter_password(passwd) self.login_page.click_login_button() assert self.login_page.wait_for_text_to_appear(rez)
def test_login_positive_case(driver_setup): with pytest.allure.step("Navigate to login screen"): driver_setup.get(config.get('JIRA', 'jira.url.ui.login')) with pytest.allure.step( "Fill in valid credentials and click 'login' button"): login_page = LoginPage(driver_setup) login_page.set_user_name(config.get('JIRA', 'jira.user')) login_page.set_password(config.get('JIRA', 'jira.password')) login_page.click_login_button() allure.attach(driver_setup.get_screenshot_as_png(), name='valid_credentials_login', attachment_type=AttachmentType.PNG) with pytest.allure.step( "Verify if user was navigated to dashboard page after successful login" ): assert driver_setup.current_url == config.get('JIRA', 'jira.url.ui.dashboard'),\ 'Actual url {} is different from Expected {}'.format( driver_setup.current_url, config.get('JIRA', 'jira.url.ui.dashboard') )
def test_login_wrong_password(driver_setup): with pytest.allure.step("Navigate to login screen"): driver_setup.get(config.get('JIRA', 'jira.url.ui.login')) with pytest.allure.step("Fill in wrong password and click 'login' button"): login_page = LoginPage(driver_setup) login_page.set_user_name(config.get('JIRA', 'jira.user')) login_page.set_password('wrong_password') login_page.click_login_button() allure.attach(driver_setup.get_screenshot_as_png(), name='wrong_password_login', attachment_type=AttachmentType.PNG) with pytest.allure.step( "Verify if user is still at login page after failed login"): assert driver_setup.current_url == config.get('JIRA', 'jira.url.ui.login'),\ 'Actual url {} is different from Expected {}'.format( driver_setup.current_url, config.get('JIRA', 'jira.url.ui.login') ) with pytest.allure.step("Verify if login error message is correct"): assert expected_login_error in login_page.get_error_text(), \ 'Actual error {} is different from Expected {}'.format(login_page.get_error_text(), expected_login_error)
def setup_and_login(driver_setup): driver_setup.get(config.get('JIRA', 'jira.url.ui.login')) login_page = LoginPage(driver_setup) login_page.set_user_name(config.get('JIRA', 'jira.user')) login_page.set_password(config.get('JIRA', 'jira.password')) login_page.click_login_button()