def test_that_list_excerpts_are_visible(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() list_items = home_page.list_items for list_item in list_items: Assert.equal(list_item.link_present, True, "Element at '%s' was not found." % list_item._item_link_locator[1])
def test_that_events_front_page_shows_upcoming_events(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() events_page = home_page.header.go_to_events_page() Assert.true(events_page.upcoming_events_count > 0) Assert.true(events_page.upcoming_events_is_visible)
def test_that_user_can_edit_profile(self, base_url, selenium, new_user): home_page = HomePage(selenium, base_url).open() home_page.login_and_complete_profile(new_user) profile_details = home_page.click_user_profile_details() edit_profile = profile_details.click_edit_profile_button() assert new_user['name'] == edit_profile.display_name assert new_user['name'] == edit_profile.username new_name = str(uuid.uuid4()) new_username = str(uuid.uuid4()).replace('-', '')[10:] edit_profile.display_name = new_name edit_profile.username = new_username edit_profile.user_profile_url = new_user['url'] edit_profile.bugzilla_email = new_user['email'] profile_details = edit_profile.click_save_button('user_profile_details') assert new_name == profile_details.user_profile_name assert new_user['url'] == profile_details.user_profile_url assert new_user['email'] == profile_details.bugzilla_email edit_profile = profile_details.click_edit_profile_button() assert new_name == edit_profile.display_name assert new_username == edit_profile.username assert new_user['url'] == edit_profile.user_profile_url assert new_user['email'] == edit_profile.bugzilla_email
def test_logout(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.login_region.login() Assert.true(home_pg.is_logged_in) home_pg.login_region.logout() Assert.false(home_pg.is_logged_in)
def test_that_resources_page_display_makes(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() resources_page = home_page.header.click_teach_tab() Assert.greater(resources_page.teach_make_count, 0) Assert.true(resources_page.is_teach_makes_visible)
def test_visitor_can_view_source(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() view_source_pg = home_pg.header_region.click_view_source() Assert.true(view_source_pg.is_the_current_page) Assert.greater(len(view_source_pg.source_textarea.strip()), 0)
def test_that_user_can_edit_profile(self, mozwebqa, new_user): home_page = HomePage(mozwebqa) home_page.go_to_page() home_page.login_and_complete_profile(new_user) profile_details = home_page.header.click_user_profile_details() edit_profile = profile_details.click_edit_profile_button() assert edit_profile.is_the_current_page assert new_user['name'] == edit_profile.display_name assert new_user['name'] == edit_profile.username new_name = str(uuid.uuid4()) new_username = str(uuid.uuid4()).replace('-', '')[10:] edit_profile.type_name(new_name) edit_profile.type_username(new_username) edit_profile.type_user_profile_url(new_user['url']) edit_profile.type_bugzilla_email(new_user['email']) profile_details = edit_profile.click_save_button('user_profile_details') assert profile_details.is_the_current_page assert new_name == profile_details.user_profile_name assert new_user['url'] == profile_details.user_profile_url assert new_user['email'] == profile_details.bugzilla_email edit_profile = profile_details.click_edit_profile_button() assert new_name == edit_profile.display_name assert new_username == edit_profile.username assert new_user['url'] == edit_profile.user_profile_url assert new_user['email'] == edit_profile.bugzilla_email
def test_visitor_can_watch_page(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() log_in_or_create_account_pg = LogInOrCreateAccountPage(mozwebqa) log_in_or_create_account_pg.log_in() Assert.false(home_pg.personal_tools_region.is_log_in_or_create_account_visible) Assert.true(home_pg.personal_tools_region.is_log_out_visible) if home_pg.header_region.is_watch_visible: watch_pg = home_pg.header_region.click_watch() Assert.true(watch_pg.is_the_current_page) Assert.equal(watch_pg.page_title, "Added to watchlist") watch_pg.click_return_to_page() Assert.true(home_pg.header_region.is_unwatch_visible) unwatch_pg = home_pg.header_region.click_unwatch() Assert.equal(watch_pg.page_title, "Removed from watchlist") unwatch_pg.click_return_to_page() Assert.true(home_pg.header_region.is_watch_visible) else: unwatch_pg = home_pg.header_region.click_unwatch() Assert.equal(watch_pg.page_title, "Removed from watchlist") unwatch_pg.click_return_to_page() Assert.true(home_pg.header_region.is_watch_visible) watch_pg = home_pg.header_region.click_watch() Assert.true(watch_pg.is_the_current_page) Assert.equal(watch_pg.page_title, "Added to watchlist") watch_pg.click_return_to_page() Assert.true(home_pg.header_region.is_unwatch_visible)
def test_visitor_can_watch_page(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() log_in_or_create_account_pg = LogInOrCreateAccountPage(mozwebqa) log_in_or_create_account_pg.log_in() Assert.true(home_pg.personal_tools_region.is_log_out_visible) # Refs bug: 1058819 home_pg.header_region.unfurl_header_dropdown() # Make sure page is not currently watched if home_pg.header_region.is_unwatch_visible: home_pg.header_region.click_unwatch() home_pg.go_to_home_page() # Refs bug: 1058819 home_pg.header_region.unfurl_header_dropdown() Assert.true(home_pg.header_region.is_watch_visible) watch_pg = home_pg.header_region.click_watch() Assert.true(watch_pg.is_the_current_page) Assert.contains('The page "Main Page" has been added to your watchlist. Future changes to this page and its associated talk page will be listed there.', watch_pg.watchlist_message) watch_pg.click_return_to_page() # Refs bug: 1058819 home_pg.header_region.unfurl_header_dropdown() Assert.true(home_pg.header_region.is_unwatch_visible) unwatch_pg = home_pg.header_region.click_unwatch() Assert.equal('The page "Main Page" has been removed from your watchlist.', unwatch_pg.watchlist_message) unwatch_pg.click_return_to_page() # Refs bug: 1058819 home_pg.header_region.unfurl_header_dropdown() Assert.true(home_pg.header_region.is_watch_visible)
def test_that_user_can_edit_profile(self, mozwebqa, existing_user): home_page = HomePage(mozwebqa) home_page.go_to_page() Assert.false(home_page.is_user_logged_in) logged_in_home_page = home_page.login(existing_user, 'home_page') Assert.true(logged_in_home_page.is_the_current_page) Assert.true(logged_in_home_page.is_user_logged_in) # click user profile details link user_profile_details_page = logged_in_home_page.header.click_user_profile_details() Assert.true(user_profile_details_page.is_the_current_page) # click edit profile button user_profile_edit_page = user_profile_details_page.click_edit_profile_button() Assert.true(user_profile_edit_page.is_the_current_page) Assert.equal(existing_user['profile']['name'], user_profile_edit_page.display_name) Assert.equal(existing_user['profile']['username'], user_profile_edit_page.username) # change display name and username new_display_name = re.sub(r'[\W_]+', '', existing_user['profile']['name'] + str(time.time())) new_username = re.sub(r'[\W_]+', '', existing_user['profile']['username'] + str(time.time())) user_profile_edit_page.enter_name(new_display_name) user_profile_edit_page.enter_username(new_username) user_profile_details_page = user_profile_edit_page.click_save_button('user_profile_details') Assert.true(user_profile_details_page.is_the_current_page) Assert.equal(new_display_name, user_profile_details_page.user_profile_name) # edit profile again user_profile_edit_page = user_profile_details_page.click_edit_profile_button() Assert.equal(new_display_name, user_profile_edit_page.display_name) Assert.equal(new_username, user_profile_edit_page.username)
def test_new_user_can_register(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() registration_pg = home_pg.login_region.click_sign_up() registration_pg.register_new_user() Assert.equal(registration_pg.page_title, u'Sign Up Complete!')
def test_valid_user_can_log_in(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() log_in_or_create_account_pg = LogInOrCreateAccountPage(mozwebqa) log_in_or_create_account_pg.log_in() Assert.true(home_pg.is_the_current_page) Assert.false(home_pg.personal_tools_region.is_log_in_or_create_account_visible, "Log in is still visible") Assert.true(home_pg.personal_tools_region.is_user_page_visible, "User page is not visible") Assert.true(home_pg.personal_tools_region.is_my_talk_visible, "Talk is not visible") Assert.true(home_pg.personal_tools_region.is_my_prefs_visible, "Preferences are not visible") Assert.true(home_pg.personal_tools_region.is_my_watchlist_visible, "Watchlist is not visible") Assert.true(home_pg.personal_tools_region.is_semantic_wl_visible, "Semantic wl is not visible") Assert.true(home_pg.personal_tools_region.is_my_contribs_visible, "My contributions are not visible") Assert.true(home_pg.personal_tools_region.is_log_out_visible, "Log out is not visible")
def test_no_results_returned_from_blank_search(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_home_page() home_page.header_region.click_search_button() Assert.true(home_page.is_the_current_page) Assert.true(home_page.get_url_current_page().endswith('/?s='))
def test_user_can_edit_page(self, mozwebqa): _edit_text_entered = 'MozWebQA Edit page wiki-test - ' + str(time.time()) home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() log_in_or_create_account_pg = LogInOrCreateAccountPage(mozwebqa) log_in_or_create_account_pg.log_in() Assert.true(home_pg.is_the_current_page) Assert.true(home_pg.personal_tools_region.is_user_page_visible) home_pg.personal_tools_region.click_user_page() if home_pg.header_region.is_edit_visible: edit_pg = home_pg.header_region.click_edit() Assert.true(edit_pg.is_edit_page_textarea_present) edit_pg.enter_edit_textarea_text(_edit_text_entered) Assert.true(edit_pg.is_edit_page_save_button_present) edit_pg.click_save_button() Assert.true(edit_pg.is_user_entered_text_saved_and_present) Assert.equal(edit_pg.get_user_entered_text, _edit_text_entered) else: Assert.fail("Error - you don't have privileges to edit this page.")
def test_graph_date_locale(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() first_date_xaxis = home_page.wait_for_element_present(By.CSS_SELECTOR, '.xAxis .ticklabel:first-child') Assert.equal('May', first_date_xaxis.text)
def test_visitor_can_view_history(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() history_pg = home_pg.header_region.click_history() Assert.true(history_pg.is_the_current_page) Assert.greater(len(history_pg.history_list.strip()), 0)
def test_that_team_list_links_are_visible(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() bad_links = [] for link in home_page.teams_links_list: if not home_page.is_element_visible(*link.get('locator')): bad_links.append('The link at %s is not visible' % link.get('locator')[1:]) Assert.equal(0, len(bad_links), '%s bad links found: ' % len(bad_links) + ', '.join(bad_links))
def test_that_getting_started_links_are_visible(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() bad_links = [] for link in home_page.getting_started_links_list: if not home_page.is_element_visible(*link.get("locator")): bad_links.append("The link at %s is not visible" % link.get("locator")[1:]) Assert.equal(0, len(bad_links), "%s bad links found: " % len(bad_links) + ", ".join(bad_links))
def test_explore_title(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() explore_page = home_page.header.click_on_explore_tab() Assert.true(explore_page.is_page_title_visible) Assert.equal('Explore - Mozilla Webmaker', explore_page._is_page_title_visible)
def test_navigation(base_url, selenium): page = HomePage(selenium, base_url).open() internet_health_page = page.navigation.open_internet_health() assert internet_health_page.seed_url in selenium.current_url page.open() technology_page = page.navigation.open_technology() assert technology_page.seed_url in selenium.current_url
def test_main_nav_link_urls_are_valid(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() bad_urls = [] for link in home_page.header.main_nav_links_list: url = home_page.link_destination(link.get('locator')) if not home_page.is_valid_link(url): bad_urls.append('%s is not a valid url' % url) Assert.equal(0, len(bad_urls), '%s bad urls found: ' % len(bad_urls) + ', '.join(bad_urls))
def test_search_selenium_from_google(self, mozwebqa): home_page = HomePage(mozwebqa) input_text = 'selenium' home_page.go_to_page() home_page.is_the_current_page home_page.search_text(input_text) home_page.search_box_submit() home_page.force_wait(1) assert home_page.is_result_output_present(), 'No results found.'
def test_main_nav_links_are_visible(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() bad_links = [] for link in home_page.header.main_nav_links_list: if not home_page.is_element_visible(link.get('locator')): bad_links.append('The link at %s is not visible' % link.get('locator')[1:]) Assert.equal(0, len(bad_links), '%s bad links found: ' % len(bad_links) + ', '.join(bad_links)) Assert.true(home_page.header.is_search_present)
def test_search_homepage(base_url, selenium): # open homepage page = HomePage(selenium, base_url).open() # search for CSS in big box search = page.search_for_term(SEARCH_TERM) # search term is in search box assert search.search_input_value == SEARCH_TERM, 'search term not preserved' # results found assert search.search_result_items_length == 10
def test_footer_link_urls_are_valid(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() bad_urls = [] for link in home_page.footer.footer_links_list: url = home_page.link_destination(link.get("locator")) if not home_page.is_valid_link(url): bad_urls.append("%s is not a valid url" % url) Assert.equal(0, len(bad_urls), "%s bad urls found: " % len(bad_urls) + ", ".join(bad_urls))
def test_main_nav_link_destinations_are_correct(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() bad_links = [] for link in home_page.header.main_nav_links_list: url = home_page.link_destination(link.get('locator')) if not url.endswith(link.get('url_suffix')): bad_links.append('%s does not end with %s' % (url, link.get('url_suffix'))) Assert.equal(0, len(bad_links), '%s bad links found: ' % len(bad_links) + ', '.join(bad_links))
def test_footer_links(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() Assert.true(home_pg.footer.is_logo_visible) Assert.true(home_pg.footer.is_feedback_link_visible) Assert.true(home_pg.footer.is_licenses_link_visible) Assert.true(home_pg.footer.is_about_link_visible) Assert.true(home_pg.footer.is_privacy_link_visible) Assert.true(home_pg.footer.is_help_link_visible)
def test_that_getting_started_link_destinations_are_correct(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() bad_links = [] for link in home_page.getting_started_links_list: url = home_page.link_destination(link.get("locator")) if not url.endswith(link.get("url_suffix")): bad_links.append("%s does not end with %s" % (url, link.get("url_suffix"))) Assert.equal(0, len(bad_links), "%s bad links found: " % len(bad_links) + ", ".join(bad_links))
def test_sign_in_and_sign_out(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() home_page.sign_in(user="******") Assert.true(home_page.is_signed_in) home_page.header.click_sign_out() Assert.false(home_page.is_signed_in)
def test_header_links(self, mozwebqa): home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() Assert.true(home_pg.header.is_topics_link_visible) Assert.true(home_pg.header.is_docs_link_visible) Assert.true(home_pg.header.is_demos_link_visible) Assert.true(home_pg.header.is_learning_link_visible) Assert.true(home_pg.header.is_community_link_visible) Assert.true(home_pg.header.is_search_present)
def test_docs_title(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_home_page() docs_page = home_page.header_region.click_docs_link() Assert.true(docs_page.is_the_current_page)
def test_masthead_displayed(base_url, selenium): page = HomePage(selenium, base_url).open() assert page.is_masthead_displayed
def test_hacks_blog(base_url, selenium): page = HomePage(selenium, base_url).open() assert page.hacks_items_length == 5 assert_valid_url(page.hacks_url, follow_redirects=True)
def test_can_add_another_email(self, mozwebqa): user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() bid_login = home_pg.click_sign_in() bid_login.sign_in_new_user(user['email'], user['password']) # Open restmail inbox, find the email inbox = RestmailInbox(user['email']) email = inbox.find_by_index(0) # Load the BrowserID link from the email in the browser mozwebqa.selenium.get(email.verify_user_link) from browserid.pages.webdriver.complete_registration import CompleteRegistration complete_registration = CompleteRegistration(mozwebqa.selenium, mozwebqa.timeout) # Check the message on the registration page reflects a successful registration! Assert.contains("Thank you for signing up with Persona.", complete_registration.thank_you) home_pg.wait_for_user_login() Assert.equal(home_pg.logged_in_user_email, user['email']) home_pg.click_logout() second_user = MockUser() bid_login = home_pg.click_sign_in(expect='returning') bid_login.sign_in_add_another_email(second_user['email']) # Open restmail inbox, find the email inbox = RestmailInbox(second_user['email']) email = inbox.find_by_index(0) # Load the BrowserID link from the email in the browser mozwebqa.selenium.get(email.add_email_address_link) from browserid.pages.webdriver.complete_registration import CompleteRegistration complete_registration = CompleteRegistration(mozwebqa.selenium, mozwebqa.timeout) home_pg.wait_for_user_login() Assert.equal(home_pg.logged_in_user_email, second_user['email']) home_pg.click_logout() bid_login = home_pg.click_sign_in(expect='returning') expected_emails = [user['email'], second_user['email']] Assert.equal(expected_emails, bid_login.emails) Assert.equal(second_user['email'], bid_login.selected_email)
def test_tweet_is_not_present(base_url, selenium): page = HomePage(base_url, selenium, 'de').open() assert not page.is_tweet_promo_present
def test_download_button_is_displayed(base_url, selenium): page = HomePage(selenium, base_url).open() assert page.download_button.is_displayed
def test_mozilla_newsletter_sign_up_fails_when_missing_required_fields( base_url, selenium): page = HomePage(base_url, selenium).open() page.mozilla_newsletter.expand_form() with pytest.raises(TimeoutException): page.mozilla_newsletter.click_sign_me_up()
def test_check_page_title(self): homepage = HomePage(self.driver) homepage.go_to_page() homepage.is_page_title_matches()
def test_main_search(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() search_page = home_page.header.click_search_tab() search_page.search('make') Assert.greater(search_page.results_count, 0)
def click_save_for_later_button(self): self.selenium.find_element( *self._save_for_later_button_locator).click() from pages.home import HomePage return HomePage(self.base_url, self.selenium).wait_for_page_to_load()
def test_header_platform_submenu(base_url, selenium): page = HomePage(selenium, base_url).open() assert page.header.is_platform_submenu_trigger_displayed assert not page.header.is_platform_submenu_displayed page.header.show_platform_submenu() assert page.header.is_platform_submenu_displayed
def test_header_signin(base_url, selenium): page = HomePage(selenium, base_url).open() # click on sign in widget page.header.trigger_signin() # assert it's fowarded to github assert 'https://github.com' in str(selenium.current_url)
def test_footer_displays(base_url, selenium): page = HomePage(selenium, base_url).open() assert page.Footer.is_displayed assert page.Footer.is_privacy_displayed assert page.Footer.is_license_displayed assert page.Footer.is_select_language_displayed
def driver(init_driver): driver = init_driver driver.get(URL) (ProductPage(driver).add_to_cart().goto_cart().goto_checkout()) yield driver HomePage(driver).logout()
def test_SearchReturnsValidResults(browser, term): home_page = HomePage(browser) results_page = ProductResultPage(browser) home_page.product_search(term) assert term in results_page.result_product_titles()[0].lower()
def click_login_button(self): elem = find_element(self._driver, AuthPageLocators.LOGIN_BUTTON_LOCATOR) elem.click() from pages.home import HomePage return HomePage(self._driver)
def test_promos_are_present(base_url, selenium): page = HomePage(base_url, selenium).open() assert page.number_of_promos_present == 16
def test_form(self): homepage = HomePage(self.driver) homepage.get_name().send_keys("Sumit") homepage.get_email().send_keys("*****@*****.**") homepage.get_pwd().send_keys("12345") homepage.get_checkbox().click() self.selectItemsByText(homepage.get_select_items(),"Male") homepage.get_radio_button().click() homepage.get_submit_button().click()
def test_login_and_logout_should_succeed(self): home_page = HomePage(self.driver).open_home_page() profile_page = home_page.header.login(USER, PASSWORD) home_page.header.logout()
def click_on_navbar_logo(self): self.selenium.find_element(*self._navbar_locator).click() from pages.home import HomePage return HomePage(self.testsetup)
def test_upcoming_events_are_displayed(base_url, selenium): page = HomePage(base_url, selenium).open() events = page.upcoming_events assert events.is_next_event_displayed assert events.is_events_list_displayed
def test_text_field_required_should_succeed(self): home_page = HomePage(self.driver).open_home_page() controls_page = home_page.header.open_controls_test_page() controls_page.submit_values()
def test_header_displays(base_url, selenium): page = HomePage(selenium, base_url).open() assert page.Header.is_displayed assert page.Header.is_menu_displayed
def test_purchase(self, wrap): # precondition driver = self.driver page = HomePage(driver) page.go_to_product() page = ProductPage(driver) page.add_to_cart() page.go_to_cart() # page.cart.click() page = CartPage(driver) page.go_to_checkout() page = CheckoutPage(driver) page.checkout_options()
def test_check_home_page_links(self): homepage = HomePage(self.driver) homepage.go_to_page() homepage.check_links(HomePage.home_page_link_list)
def test_LogoDisplayed(browser): home_page = HomePage(browser) assert home_page.verify_logo_displayed()
def test_check_header_links(self): homepage = HomePage(self.driver) homepage.go_to_page() homepage.check_links(BasePage.header_link_list)
def click_save_for_later_button(self): self.selenium.find_element( *self._save_for_later_button_locator).click() from pages.home import HomePage return HomePage(self.testsetup)
def test_get_firefox_link_is_displayed(base_url, selenium): page = HomePage(selenium, base_url).open() assert page.is_get_firefox_link_displayed
def test_that_search_button_is_available(self, mozwebqa): home_page = HomePage(mozwebqa) home_page.go_to_page() Assert.true(home_page.is_search_button_available)