def login_to_jira(request, browser): from src.pages.login_page import LoginPage from src.pages.main_page import MainPage login_page = LoginPage(browser) main_page = MainPage(browser) with allure.step("Open login page"): login_page.open() with allure.step("Login to JIRA"): login_page.login(login, password) def take_screenshot(): with allure.step("Taking screenshot"): browser.execute_script("document.body.bgColor = 'white';") allure.attach(browser.get_screenshot_as_png(), name=request.function.__name__, attachment_type=allure.attachment_type.PNG) request.addfinalizer(take_screenshot) with allure.step("Wait until main page is loaded"): main_page.wait_until_loaded() yield main_page with allure.step("Logout from JIRA"): main_page.logout()
def test_web_ui_13_check_auth_page_change_pass_link(self, browser): auth_page = LoginPage(browser) auth_page.open() with wait_for_page_to_reload(browser): auth_page.click_forget_pass_btn() assert_that(browser.current_url, contains_string(ChangePassPage(browser).path), 'Страница "Новый пароль" не открылась')
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()
def test_login_correct_creds(self, browser): login_page = LoginPage(browser) main_page = MainPage(browser) with allure.step("Open login page"): login_page.open() with allure.step("Check that login page opened"): assert login_page.at_page() with allure.step("Login to JIRA with correct credentials"): login_page.login(login, password) allure.attach(browser.get_screenshot_as_png(), name="login_correct_creds1", attachment_type=allure.attachment_type.PNG) with allure.step("Check that main page opened"): assert main_page.at_page() allure.attach(browser.get_screenshot_as_png(), name="test_login_correct_creds2", attachment_type=allure.attachment_type.PNG) with allure.step("Logout from JIRA"): logout_page = main_page.logout() with allure.step("Cheсk that logout page appears"): assert logout_page.at_page() with allure.step("Open login page"): login_page.open() with allure.step("Check that login page opened"): assert login_page.at_page() allure.attach(browser.get_screenshot_as_png(), name="test_logout", attachment_type=allure.attachment_type.PNG)
def test_web_ui_12_auth_page_authorization_error(self, browser): auth_page = LoginPage(browser) auth_page.open() auth_page.fill_login_field(login=str(random.randint(9100000000, 9109999999))) auth_page.fill_password_field(password=''.join(random.choice(string.ascii_lowercase) for _ in range(5))) auth_page.click_submit_btn() assert_that(auth_page.is_error_msg_displayed(), 'Не отображается ошибка "Неверный телефон или пароль"')
def test_web_ui_11_auth_page_empty_field_error(self, browser): auth_page = LoginPage(browser) auth_page.open() auth_page.fill_login_field(login=UserData.trial_tariff.value.login) auth_page.click_submit_btn() assert_that(browser.current_url, contains_string(LoginPage(browser).path), 'Пользователь авторизован без пароля')
def test_web_ui_10_check_auth_page_authorization(self, browser): auth_page = LoginPage(browser) auth_page.open() auth_page.log_in(browser=browser, login=UserData.trial_tariff.value.login, password=UserData.trial_tariff.value.password) assert_that(browser.current_url, contains_string(LKPage(browser).path), 'Страница "Личный кабинет" не открылась')
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 TestJiraLoginUI: @pytest.mark.smoke def test_login_to_jira(self, browser): self.login_page = LoginPage(browser) self.login_page.open("http://jira.hillel.it:8080/secure/Dashboard.jspa") assert self.login_page.at_page() self.login_page.login_to_jira_enter_username("webinar5") self.login_page.login_to_jira_enter_password("webinar5") self.login_page.click_login_button_at_main_page() self.main_page = MainPage(browser) self.main_page.is_assigned_to_me_section() assert self.main_page.is_assigned_to_me_section()
def test_login_incorrect_password(self, browser): login_page = LoginPage(browser) with allure.step("Open login page"): login_page.open() with allure.step("Check that login page opened"): assert login_page.at_page() with allure.step("Call login method"): login_page.login(login, "wrong") with allure.step("Check that correct error is displayed"): assert login_page.username_error_text("Sorry, your username and password are incorrect") allure.attach(browser.get_screenshot_as_png(), name="test_login_incorrect_password", attachment_type=allure.attachment_type.PNG)
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 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 auth_by_paid_tariff(browser): auth_page = LoginPage(browser) auth_page.open() auth_page.log_in(browser=browser, login=UserData.paid_tariff.value.login, password=UserData.paid_tariff.value.password)
class TestLogin(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.url = 'https://www.haixinglian.com/passport-signin.html' #self.username = '******' #self.password = '******' self.excel = excel_data.Excel() self.login_page = LoginPage(self.driver, self.url, u'海星链') def test_login_search(self): u'''正常登录''' try: keyword_list = self.excel.get_list( test_data_path + 'login_data.xlsx', 'Sheet1') for i in range(0, len(keyword_list)): username = keyword_list[i]["用户名"] password = keyword_list[i]["密码"] if type(username) != str: username = int(username) username = str(username) if type(password) != str: password = str(password) self.login_page.open() self.login_page.input_username(username) self.login_page.input_password(password) self.login_page.click_login() sleep(2) self.assertIn(username, self.driver.find_element_by_id('uname_110').text) self.driver.find_element_by_xpath( '//*[@id="member_110"]/a[3]').click() except Exception as e: self.login_page.img_screenshot(u'登陆异常') raise e def test_jump_forget(self): u'''跳转到找回密码页''' try: for i in range(2): self.login_page.open() self.login_page.click_forget_password() self.assertIn( u'找回密码', self.driver.find_element_by_xpath( '/html/body/div[2]/div/h1').text) except Exception as e: self.login_page.img_screenshot(u'跳转到找回密码页失败') raise e def test_jump_register1(self): u'''跳转到注册页''' try: self.login_page.open() self.login_page.click_register1() self.assertIn( u'采购商认证页', self.driver.find_element_by_xpath( '/html/body/div[1]/div/div/div[2]/div[1]/span[1]').text) except Exception as e: self.login_page.img_screenshot(u'登陆_跳转到注册页失败') raise e def test_jump_register2(self): u'''跳转到注册页''' try: self.login_page.open() self.login_page.click_register2() self.assertIn( u'采购商认证页', self.driver.find_element_by_xpath( '/html/body/div[1]/div/div/div[2]/div[1]/span[1]').text) except Exception as e: self.login_page.img_screenshot(u'登陆_跳转到注册页失败') raise e def test_jump_offline(self): u'''跳转到线下体验''' try: self.login_page.open() sleep(3) self.login_page.click_offline() #driver.find_element_by_xpath('//*[@id="header"]/div/div/div[2]/span[2]/a').click() self.assertIn( 'Ture', self.driver.find_element_by_xpath( '//*[@id="nav"]/div/div/div[2]/div/a[4]').is_selected()) except Exception as e: self.login_page.img_screenshot(u'跳转线下体验失败') def test_jump_WeChat(self): u'''跳转到微信''' try: self.login_page.open() self.login_page.click_WeChat_login() #print(self.driver.title) self.assertIn('Log In to WeChat', self.driver.title) except Exception as e: self.login_page.img_screenshot(u'登陆_跳转到微信失败') raise e def test_jump_QQ(self): u'''跳转到QQ''' try: self.login_page.open() self.login_page.click_QQ_login() self.assertIn('QQ帐号安全登录', self.driver.title) except Exception as e: self.login_page.img_screenshot(u'登陆_跳转到QQ失败') raise e def tearDown(self): self.driver.close()
class TestJiraLoginUI: @pytest.mark.smoke def test_login_to_jira(self, browser): self.login_page = LoginPage(browser) self.login_page.open(url_ui) assert self.login_page.at_page() self.login_page.login_to_jira_enter_username(global_user) self.login_page.login_to_jira_enter_password(global_pass) self.login_page.click_login_button_at_main_page() self.main_page = MainPage(browser) assert self.main_page.is_assigned_to_me_section() @pytest.mark.smoke def test_create_issue_in_jira(self, browser): self.login_page = LoginPage(browser) self.login_page.open( "http://jira.hillel.it:8080/secure/Dashboard.jspa") assert self.login_page.at_page() self.login_page.login_to_jira_enter_username("webinar5") self.login_page.login_to_jira_enter_password("webinar5") self.login_page.click_login_button_at_main_page() self.main_page = MainPage(browser) assert self.main_page.is_assigned_to_me_section() self.main_page.click_create_issue_button() self.create_issue_page = CreateIssue(browser) self.create_issue_page.should_have_title("Create Issue") self.create_issue_page.choose_the_project("Webinar (WEBINAR)") self.create_issue_page.enter_summary_field("UI bug In Jira") self.create_issue_page.enter_reporter("webinar5") self.create_issue_page.click_create_issue_button_at_details_page() assert "Issue" in self.create_issue_page.is_alert_present() @pytest.mark.regression def test_add_comment_to_the_ticket(self, browser): self.login_page = LoginPage(browser) self.login_page.open("https://jira.hillel.it/browse/WEBINAR-9060") self.login_page.login_to_jira_enter_username("webinar5") self.login_page.login_to_jira_enter_password("webinar5") self.login_page.click_login_button_at_login_page() self.comment_page_page = CommentPage(browser) self.comment_page_page.click_comment_button() self.comment_page_page.enter_comment_text("comment_text") self.comment_page_page.click_add_comment_button() assert not self.comment_page_page.comment_input_field_at_page( ), "Comment not added" @pytest.mark.regression def test_change_assigner_for_the_ticket(self, browser): self.login_page = LoginPage(browser) self.login_page.open( "http://jira.hillel.it:8080/secure/Dashboard.jspa") self.login_page.login_to_jira_enter_username("webinar5") self.login_page.login_to_jira_enter_password("webinar5") self.login_page.click_login_button_at_main_page() self.main_page = MainPage(browser) self.main_page.click_the_first_ticket_assigned_to_me() self.issue_details_page = IssueDetailsPage(browser) self.issue_details_page.click_issue_reporter_field() self.issue_details_page.enter_new_reporter("Artur Piluck") assert self.issue_details_page.should_be_new_assigner("Artur Piluck") self.issue_details_page.refresh_the_page() assert self.issue_details_page.should_be_new_assigner("Artur Piluck") @pytest.mark.regression @pytest.mark.parametrize("login, password, rez", [ ("admin", "password", "Sorry, your username and password are incorrect - please try again.") ]) def test_with_invalid_login_to_jira(self, browser, login, password, rez): self.login_page = LoginPage(browser) self.login_page.open(url_ui) assert self.login_page.at_page() self.login_page.login_to_jira_enter_username(login) self.login_page.login_to_jira_enter_password(password) self.login_page.click_login_button_at_main_page() assert self.login_page.is_invalid_message_present(rez)
def test_web_ui_9_check_auth_page_locators(self, browser): auth_page = LoginPage(browser) auth_page.open() auth_page.check_all_elements()