def test_that_whats_this_link_for_source_license_links_to_an_answer_in_faq(self, mozwebqa): """Test for Litmus 11530.""" details_page = Details(mozwebqa, "Firebug") details_page.expand_version_information() user_faq_page = details_page.click_whats_this_license() Assert.not_none(re.match('(\w+\s*){3,}', user_faq_page.license_question)) Assert.not_none(re.match('(\w+\s*){3,}', user_faq_page.license_answer))
def test_that_reviews_are_displayed(self, mozwebqa): """Test for Litmus 9890.""" details_page = Details(mozwebqa, "Firebug") Assert.equal(details_page.review_title, "Reviews") Assert.true(details_page.has_reviews) for review in details_page.review_details: Assert.not_none(review)
def test_that_reviews_are_displayed(self, mozwebqa): """ Test for Litmus 9890""" details_page = Details(mozwebqa, "Firebug") Assert.true(details_page.is_review_title_visible) Assert.equal(details_page.review_title, "Reviews") Assert.true(details_page.has_reviews) Assert.not_none(re.search("(\w+\s*){1,}", details_page.review_details))
def test_create_request(db_session, soap_client): global request_id # Find template guid template_guid = None for name, guid in db_session.query(db.Vm.name, db.Vm.guid).filter(db.Vm.template==True): if 'cfme' in name.lower(): template_guid = guid.strip() logging.info('Using (%s,%s) template.' % (name, guid)) break else: raise Exception("Couldn't find CFME template for provisioning smoke test") Assert.not_none(template_guid) # Generate provision request template_fields = soap_client.pipeoptions({ 'guid': template_guid, }) # VMWare vm_fields = soap_client.pipeoptions({ 'number_of_cpu': 1, 'vm_memory': 1024, 'vm_name': vm_name, }) requester = soap_client.pipeoptions({ 'owner_first_name': 'tester', 'owner_last_name': 'testee', 'owner_email': '*****@*****.**', }) result = soap_client.service.VmProvisionRequest('1.1', template_fields, vm_fields, requester, '', '') request_id = result.id
def test_that_reviews_are_displayed(self, mozwebqa): """ Test for Litmus 9890""" amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug") Assert.true(amo_details_page.is_review_title_visible()) Assert.equal(amo_details_page.review_title, "Reviews") Assert.true(amo_details_page.has_reviews) Assert.not_none(re.search('(\w+\s*){1,}', amo_details_page.review_details))
def __init__(self): logging.basicConfig(level=logging.INFO) # TODO: Set these by configuration in the future # logging.getLogger('suds.client').setLevel(logging.DEBUG) # logging.getLogger('suds.transport').setLevel(logging.DEBUG) # change mozwebqa.cfg hard coded path to read off config arg f = open("../../cfme_pages/mozwebqa.cfg", "r") content = f.read().split("\n") intermediate = [(x.split("=")[0].strip(), x.split("=")[1].strip()) for x in content if len(x.split("=")) == 2] env_config = dict(intermediate) f.close() # change credential.cfg hard coded path to read off config arg f = open("../../cfme_pages/credentials.yaml", "r") user_config = yaml.load(f) f.close() self.u = user_config["default"]["username"] self.p = user_config["default"]["password"] self.evm_server_hostname = env_config["baseurl"].strip("https://") url = "%s/vmdbws/wsdl/" % env_config["baseurl"] t = HttpAuthenticated(username=self.u, password=self.p) imp = Import("http://schemas.xmlsoap.org/soap/encoding/") d = ImportDoctor(imp) self.client = Client(url, transport=t, doctor=d) Assert.not_none(self.client)
def test_filtering_apps_by_price(self, mozwebqa, search_filter): home_page = Home(mozwebqa) home_page.go_to_homepage() Assert.true(home_page.is_the_current_page) search_page = home_page.header.search("") result_count_before_filter = search_page.results_count Assert.greater(result_count_before_filter, 0, "No results on the page") search_page.filter_by(search_filter).click() result_count_after_filter = search_page.results_count Assert.greater_equal(result_count_before_filter, result_count_after_filter) Assert.contains(search_filter, search_page.applied_filters) if search_filter == "Free Only": [ Assert.equal("FREE", result.price) for result in search_page.results ] elif search_filter == "Premium Only": for result in search_page.results: Assert.not_none(re.match("\$\d+.\d+", result.price))
def test_value_of_timestamp_link(self, mozwebqa): themes_pg = ThemesPage(mozwebqa) themes_pg.go_to_themes_page() theme_pg = themes_pg.themes[0].click_similar_messages() for message in theme_pg.messages: Assert.not_none(re.match('(\d+ \w+ ago)|(\w{3} \d{1,2}, \d{4})', message.time))
def test_about_page(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() about_page = home_page.click_about_nav_button() Assert.equal(home_page.header, "About Affiliates") Assert.true(about_page.is_the_current_url) Assert.not_none(about_page.about_text)
def test_value_of_timestamp_link(self, testsetup): themes_pg = themes_page.ThemesPage(testsetup) themes_pg.go_to_themes_page() themes_pg.themes[0].click_similar_messages() theme_pg = theme_page.ThemePage(testsetup) for message in theme_pg.messages: Assert.not_none(re.match('\d+ \w+ \w+', message.time))
def is_the_current_page(self): # This overrides the method in the Page super class. actual_page_title = self.page_title Assert.not_none( re.match(self._page_title_regex, actual_page_title), 'Expected the current page to be the themes detail page.\n Actual title: %s' % actual_page_title) return True
def test_that_whats_this_link_for_source_license_links_to_an_answer_in_faq( self, mozwebqa): details_page = Details(mozwebqa, "Firebug") details_page.expand_version_information() user_faq_page = details_page.click_whats_this_license() Assert.not_none( re.match('(\w+\s*){3,}', user_faq_page.license_question)) Assert.not_none(re.match('(\w+\s*){3,}', user_faq_page.license_answer))
def test_the_developers_comments_section(self, mozwebqa): details_page = Details(mozwebqa, 'Firebug') Assert.equal(details_page.devs_comments_title, u"Developer\u2019s Comments") details_page.expand_devs_comments() Assert.true(details_page.is_devs_comments_section_expanded) Assert.not_none( re.match('(\w+\s*){3,}', details_page.devs_comments_message))
def test_value_of_timestamp_link(self, mozwebqa): themes_pg = ThemesPage(mozwebqa) themes_pg.go_to_themes_page() theme_pg = themes_pg.themes[0].click_similar_messages() for message in theme_pg.messages: Assert.not_none( re.match('(\d+ \w+ ago)|(\w{3} \d{1,2}, \d{4})', message.time))
def test_about_page(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() about_page = home_page.click_about_nav_button() Assert.equal(home_page.header, 'About Affiliates') Assert.true(about_page.is_the_current_url) Assert.not_none(about_page.about_text)
def is_the_current_page(self): # This overrides the method in the Page super class. actual_page_title = self.page_title Assert.not_none( re.match(self._page_title_regex, actual_page_title), "Expected the current page to be the themes detail page.\n Actual title: %s" % actual_page_title, ) return True
def test_that_the_development_channel_expands(self, mozwebqa): details_page = Details(mozwebqa, 'Firebug') Assert.equal("Development Channel", details_page.development_channel_text) Assert.equal('', details_page.development_channel_content) details_page.click_development_channel() Assert.not_none(details_page.development_channel_content) details_page.click_development_channel() Assert.equal('', details_page.development_channel_content)
def test_that_version_information_is_displayed(self, mozwebqa): """ Test for Litmus 9890""" amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug") Assert.true(amo_details_page.is_version_information_heading_visible()) Assert.equal(amo_details_page.version_information_heading, "Version Information") Assert.not_none(re.search('\w+', amo_details_page.release_version)) # check that the release number matches the the version number at the top of the page Assert.not_none(re.search(amo_details_page.version_number, amo_details_page.release_version))
def test_that_release_notes_are_displayed(self, testsetup): """ Test for Litmus 9890""" amo_details_page = AddonsDetailsPage(testsetup, "Firebug") Assert.true(amo_details_page.are_release_notes_visible()) Assert.equal(amo_details_page.release_notes, "Release Notes") Assert.not_none(re.match('\w+', amo_details_page.version_number)) #check that the release number matches the the version number at the top of the page Assert.not_none(re.search(amo_details_page.version_number, amo_details_page.release_version))
def test_that_license_link_works(self, mozwebqa): """ Test for Litmus 25726. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=25726 """ addon_name = 'Firebug' details_page = Details(mozwebqa, addon_name) Assert.equal(details_page.license_link_text, 'BSD License') license_link = details_page.license_site Assert.not_none(license_link)
def test_the_developers_comments_section(self, mozwebqa): """ Test for Litmus 25724. https://litmus.mozilla.org/show_test.cgi?id=25724 """ details_page = Details(mozwebqa, 'Firebug') Assert.equal(details_page.devs_comments_title, u"Developer\u2019s Comments") details_page.expand_devs_comments() Assert.true(details_page.is_devs_comments_section_expanded) Assert.not_none(re.match('(\w+\s*){3,}', details_page.devs_comments_message))
def test_view_source_addon(self, mozwebqa): #This test is to check viewing the source of an addon while not logged in homepage_obj = HomePage(mozwebqa) #Go to search page and click view source on the first addon listed homepage_obj.go_to_home_page() searchpage_obj = homepage_obj.header.click_search() addoneditor_obj = searchpage_obj.addon(1).click() # TODO: wtf Assert.true(addoneditor_obj.tab(1).selected) Assert.not_none(addoneditor_obj.tab(1).content)
def test_view_source_library(self, mozwebqa): #This test is to check viewing the source of a library while not logged in homepage_obj = HomePage(mozwebqa) #Go to search page and click view source on the first library listed homepage_obj.go_to_home_page() searchpage_obj = homepage_obj.header.click_search() libraryeditor_obj = searchpage_obj.library(1).click() Assert.true(libraryeditor_obj.tab(1).selected) Assert.not_none(libraryeditor_obj.tab(1).content)
def test_that_learn_more_link_is_correct(self, mozwebqa): """Test for Litmus 15326.""" #browser initial_page = Details(mozwebqa, 'MemChaser') #api addons_xml = AddOnsAPI(mozwebqa) learn_more_url = addons_xml.get_learn_more_url(self.firebug) addons_xml.goto_url_from_xml(learn_more_url) Assert.not_none(re.search(self.firebug, initial_page.page_title))
def test_check_request_status(): start_time = time() while (time() - start_time < 300): # Give EVM 5 mins to move to change status result = client.service.GetVmProvisionRequest(request_id) #print "this is the get_prov_request result:", result if result.approval_state == 'approved': Assert.equal(result.status, 'Ok') vm_guid = result.vms[0].guid break time.sleep(30) # 30s nap Assert.not_none(vm_guid)
def test_the_developers_comments_section(self, mozwebqa): """ Test for Litmus 25724. https://litmus.mozilla.org/show_test.cgi?id=25724 """ details_page = Details(mozwebqa, 'Firebug') Assert.equal(details_page.devs_comments_title, u"Developer\u2019s Comments") details_page.expand_devs_comments() Assert.true(details_page.is_devs_comments_section_expanded) Assert.not_none( re.match('(\w+\s*){3,}', details_page.devs_comments_message))
def test_the_development_channel_section(self, mozwebqa): details_page = Details(mozwebqa, 'Firebug') Assert.equal('Development Channel', details_page.development_channel_text) details_page.click_development_channel() # Verify if description present Assert.not_none(details_page.development_channel_content) Assert.true(details_page.is_development_channel_install_button_visible) # Verify experimental version (beta or pre) Assert.not_none(re.match('Version\s\d+\.\d+\.\d+[a|b|rc]\d+\:', details_page.beta_version))
def test_that_selecting_nightly_builds_loads_page_and_link_to_ftp_works(self, mozwebqa): csp = CrashStatsHomePage(mozwebqa) nightly_builds_page = csp.header.select_report('Nightly Builds') Assert.equal(nightly_builds_page.product_header, 'Nightly Builds for Firefox') website_link = nightly_builds_page.link_to_ftp #check that the link is valid Assert.not_none(re.match('(\w+\W+)', website_link)) #test external link works nightly_builds_page.click_link_to_ftp() Assert.equal(website_link, nightly_builds_page.get_url_current_page(), nightly_builds_page.get_url_current_page())
def test_snippets_image_present(self, mozwebqa, path): full_url = mozwebqa.base_url + path soup = self._parse_response(self._get_redirect(full_url).content) snippets = soup.select("div.snippet") snippet_icons = soup.select("div.snippet img.icon") Assert.equal(len(snippets), len(snippet_icons), "Snippets do not match Snippet icons") Assert.greater(len(snippets), 0, "No snippets found") for img in snippet_icons: Assert.not_none(img['src'], "Snippet icon src not found")
def test_that_the_development_channel_expands(self, mozwebqa): """ Test for Litmus 25711. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=25711 """ details_page = Details(mozwebqa, 'Firebug') Assert.equal("Development Channel", details_page.development_channel_text) Assert.equal('', details_page.development_channel_content) details_page.click_development_channel() Assert.not_none(details_page.development_channel_content) details_page.click_development_channel() Assert.equal('', details_page.development_channel_content)
def test_that_selecting_nightly_builds_loads_page_and_link_to_ftp_works( self, mozwebqa): csp = CrashStatsHomePage(mozwebqa) nightly_builds_page = csp.header.select_report('Nightly Builds') Assert.equal(nightly_builds_page.page_heading, 'Nightly Builds for Firefox') website_link = nightly_builds_page.link_to_ftp #check that the link is valid Assert.not_none(re.match('(\w+\W+)', website_link)) #test external link works nightly_builds_page.click_link_to_ftp() Assert.equal(website_link, nightly_builds_page.get_url_current_page())
def test_faq_page(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() faq_page = home_page.click_faq_nav_button() Assert.equal(home_page.header, "FAQs") Assert.true(faq_page.is_the_current_url) Assert.true(faq_page.questions_count > 0) # Pick one question from each section for i in range(4): i += 1 Assert.not_none(faq_page.questions_text) faq_page.expand_question_by_section(i) Assert.not_none(faq_page.answer(i))
def test_get_started_3_steps(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() Assert.true(home_page.is_the_current_url) Assert.greater(home_page.category_count, 0, "There is no categories in list") Assert.not_none(home_page.categories[0].name) Assert.true(home_page.is_step_button_selected("first")) # Select first Category in list home_page.categories[0].select_category() Assert.true(home_page.is_step_button_selected("second")) Assert.not_none(home_page.categories[0].name) # Select first Banner in list home_page.categories[0].select_category() Assert.true(home_page.is_step_button_selected("third"))
def test_the_development_channel_section(self, mozwebqa): details_page = Details(mozwebqa, 'Firebug') Assert.equal('Development Channel', details_page.development_channel_text) details_page.click_development_channel() # Verify if description present Assert.not_none(details_page.development_channel_content) Assert.true(details_page.is_development_channel_install_button_visible) # Verify experimental version (beta or pre) Assert.not_none( re.match('Version\s\d+\.\d+\.\d+[a|b|rc]\d+\:', details_page.beta_version))
def test_get_started_3_steps(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() Assert.true(home_page.is_the_current_url) Assert.greater(home_page.category_count, 0, 'There are no categories in the list') Assert.not_none(home_page.categories[0].name) Assert.true(home_page.is_step_button_selected('first')) # select the first category in the list home_page.categories[0].select_category('second') Assert.true(home_page.is_step_button_selected('second')) Assert.not_none(home_page.categories[0].name) # select the first banner in list home_page.categories[0].select_category('third') Assert.true(home_page.is_step_button_selected('third'))
def test_faq_page(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() faq_page = home_page.click_faq_nav_button() Assert.equal(home_page.header, 'FAQs') Assert.true(faq_page.is_the_current_url) Assert.true(faq_page.questions_count > 0) #Pick one question from each section for i in range(4): i += 1 Assert.not_none(faq_page.questions_text) faq_page.expand_question_by_section(i) Assert.not_none(faq_page.answer(i))
def test_the_development_channel_section(self, mozwebqa): """ Test for Litmus 25732. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=25732 """ details_page = Details(mozwebqa, 'Firebug') Assert.equal('Development Channel', details_page.development_channel_text) details_page.click_development_channel() # Verify if description present Assert.not_none(details_page.development_channel_content) Assert.true(details_page.is_development_channel_install_button_visible) # Verify experimental version (beta or pre) Assert.not_none(re.match('Version \d\.\d.\d(b|a|rc)[0-9]:', details_page.beta_version))
def test_about_page_has_proper_layout(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() about_page = home_page.click_about_nav_link() Assert.true(about_page.is_the_current_url) Assert.equal(about_page.faq_header, 'Frequently Asked Questions', 'Expected title: Frequently Asked Questions') Assert.not_none(about_page.about_text, 'about page has no text to display') Assert.true(about_page.category_count > 0, 'FAQ category not present') Assert.true(about_page.questions_count > 0, 'No faq questions present in about page') about_page = home_page.click_about_nav_link() Assert.equal(about_page.questions_count, about_page.answers_count, 'Questions count did not match answers count')
def test_the_development_channel_section(self, mozwebqa): """ Test for Litmus 25732. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=25732 """ details_page = Details(mozwebqa, 'Firebug') Assert.equal('Development Channel', details_page.development_channel_text) details_page.click_development_channel() # Verify if description present Assert.not_none(details_page.development_channel_content) Assert.true(details_page.is_development_channel_install_button_visible) # Verify experimental version (beta or pre) Assert.not_none( re.match('Version\s\d+\.\d+\.\d+[a|b|rc]\d+\:', details_page.beta_version))
def test_check_request_status(soap_client): global vm_guid Assert.not_none(request_id) start_time = time() while (time() - start_time < 300): # Give EVM 5 mins to change status result = soap_client.service.GetVmProvisionRequest(request_id) if result.approval_state == 'approved': if result.status == 'Error': pytest.fail(result.message) Assert.equal(result.status, 'Ok') try: global vm_guid vm_guid = result.vms[0].guid except IndexError: # So result.vms was [] logging.info('Result from provision request \ did not have any VM associated with it: %s' % result.vms) break sleep(30) # 30s nap
def test_create_request(db_session, soap_client): global request_id # Find template guid template_guid = None for name, guid in db_session.query( db.Vm.name, db.Vm.guid).filter(db.Vm.template == True): if 'cfme' in name.lower(): template_guid = guid.strip() logging.info('Using (%s,%s) template.' % (name, guid)) break else: raise Exception( "Couldn't find CFME template for provisioning smoke test") Assert.not_none(template_guid) # Generate provision request template_fields = soap_client.pipeoptions({ 'guid': template_guid, }) # VMWare vm_fields = soap_client.pipeoptions({ 'number_of_cpu': 1, 'vm_memory': 1024, 'vm_name': vm_name, }) requester = soap_client.pipeoptions({ 'owner_first_name': 'tester', 'owner_last_name': 'testee', 'owner_email': '*****@*****.**', }) result = soap_client.service.VmProvisionRequest('1.1', template_fields, vm_fields, requester, '', '') request_id = result.id
def test_filtering_apps_by_price(self, mozwebqa, search_filter): home_page = Home(mozwebqa) home_page.go_to_homepage() Assert.true(home_page.is_the_current_page) search_page = home_page.header.search("") result_count_before_filter = search_page.results_count Assert.greater(result_count_before_filter, 0, "No results on the page") search_page.filter_by(search_filter).click() result_count_after_filter = search_page.results_count Assert.greater_equal(result_count_before_filter, result_count_after_filter) Assert.contains(search_filter, search_page.applied_filters) if search_filter == "Free Only": [Assert.equal("FREE", result.price) for result in search_page.results] elif search_filter == "Premium Only": for result in search_page.results: Assert.not_none(re.match("\$\d+.\d+", result.price))
def test_verify_layout_logged_in_user(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() edit_page = home_page.click_profile() Assert.true(edit_page.is_stats_section_visible()) Assert.true(edit_page.is_stats_ranking_visible()) Assert.not_none(edit_page.stats_ranking, 'Stats rankings is null') Assert.true(edit_page.is_stats_banners_visible()) Assert.not_none(edit_page.stats_banners, 'Stats banners is null') Assert.true(edit_page.is_stats_clicks_visible()) Assert.not_none(edit_page.stats_clicks, 'Stats clickss is null') Assert.true(edit_page.is_milestones_section_visible()) Assert.true(edit_page.is_newsletter_form_visible())
def test_that_license_link_works(self, mozwebqa): addon_name = 'Firebug' details_page = Details(mozwebqa, addon_name) Assert.equal(details_page.license_link_text, 'BSD License') license_link = details_page.license_site Assert.not_none(license_link)
def test_stop_vm(soap_client): Assert.not_none(vm_guid) result = soap_client.service.EVMSmartStart(vm_guid) Assert.equal(result.result, 'true') return test_start_vm
def test_that_addon_name_is_displayed(self, mozwebqa): details_page = Details(mozwebqa, "Firebug") # check that the name is not empty Assert.not_none(details_page.title, "")
def test_that_summary_is_displayed(self, mozwebqa): details_page = Details(mozwebqa, "Firebug") # check that the summary is not empty Assert.not_none(re.match('(\w+\s*){3,}', details_page.summary))
def test_that_about_this_addon_is_displayed(self, mozwebqa): details_page = Details(mozwebqa, "Firebug") Assert.equal(details_page.about_addon, "About this Add-on") Assert.not_none(re.match('(\w+\s*){3,}', details_page.description))
def test_that_not_none_passes(self): Assert.not_none(1) Assert.not_none("a") Assert.not_none("a" in "bad")
restmail_url = 'https://restmail.net/mail/' + testuser_email.split('@')[0] response_json = [] while timer < timeout: sleep(1) timer += 1 response = requests.get(restmail_url, verify=False) response_json = json.loads(response.content) if response.json != []: break Assert.not_equal(timer, timeout, "restmail timed out") # ok, we got the inbox, assume the email is the first message. # grab the first message and find the verify link verify_regex = 'https:\/\/.*verify_email_address\?token=.{48}' verify_link = re.search(verify_regex, response_json[0]['text']).group(0) Assert.not_none(verify_link, "verify link not found in acct creation email") # switch to the main window and open up that link # verify that the page says success message # verify that the redirect happens # verify that the dialog got dismissed # verify that you're actually logged in # go ahead and log out :-) it's all good now # problems to talk about -- maybe move this to the next file. # - first off, you can't, ever, use XPaths to find elements. so brittle. # - you don't want to hard-code selectors, since the class names could change. # - but beyond that, what you really want is to abstract out, not just # selectors, but all the low-level page interactions: abstract out the
def test_get_vm(soap_client): Assert.not_none(vm_guid) result = soap_client.service.EVMGetVm(vm_guid) Assert.equal(result.name, vm_name) Assert.equal(result.guid, vm_guid)
def test_about_text_present(self, mozwebqa): start_page = StartPage(mozwebqa) home_page = start_page.login() about_page = home_page.click_about_nav_link() Assert.not_none(about_page.about_text)