def test_that_new_review_is_saved(self, mozwebqa):
        """ Litmus 22921
            https://litmus.mozilla.org/show_test.cgi?id=22921 """
        # Step 1 - Login into AMO
        amo_home_page = AddonsHomePage(mozwebqa)
        credentials = mozwebqa.credentials['default']
        amo_home_page.header.click_login()
        addons_login_page = AddonsLoginPage(mozwebqa)
        addons_login_page.login(credentials['email'], credentials['password'])
        Assert.true(amo_home_page.header.is_user_logged_in)

        # Step 2 - Load any addon detail page
        details_page = AddonsDetailsPage(mozwebqa, 'Adblock Plus')

        # Step 3 - Click on "Write review" button
        write_review_block = details_page.click_to_write_review()

        # Step 4 - Write a review
        body = 'Automatic addon review by Selenium tests'
        write_review_block.enter_review_with_text(body)
        write_review_block.set_review_rating(1)
        review_page = write_review_block.click_to_save_review()

        # Step 5 - Assert review
        review = review_page.review()
        Assert.equal(review.rating, 1)
        Assert.equal(review.author, credentials['name'])
        date = datetime.now().strftime("%B %d, %Y")
        # there are no leading zero-signs on day so we need to remove them too
        date = date.replace(' 0', ' ')
        Assert.equal(review.date, date)
        Assert.equal(review.text, body)
 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 test_first_author_name(self, testsetup):  #ok in impala
     #Firebug test
     #Assert.equal("Joe Hewitt",self.selenium.get_text("//h4[@class='author']/a[1]"))
     #Tab Mix Plus test
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.equal("onemen",
                  tab_mix_plus_page.get_text("//h4[@class='author']/a[1]"))
 def test_summary_locator(self, testsetup):
     #This was written as the details page was being upgraded, thus 2 locators.
     new_impala_summary_locator = "css=p[id=addon-summary]"
     old_zamboni_summary_locator = "css=div[id=addon-summary]>p"
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(
         tab_mix_plus_page.is_element_present(old_zamboni_summary_locator))
 def test_icon_locator(self, testsetup): #broken in impala
     #Firebug icon
     #image_url = "https://static-cdn.addons.mozilla.net/en-US/firefox/images/addon_icon/1843-32.png?modified=1300780225"   
     #Tab Mix Plus icon        
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     image_url = "https://gs1.adn.edgecastcdn.net/801237/addons-cdn.allizom.org/en-US/firefox/images/addon_icon/1122-32.png?modified=1305054615" #?modified=1305054615"     
     Assert.true(tab_mix_plus_page.is_element_present("css=input[type=img], [src=" +  image_url + "]"))
    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_report_abuse_link_popup(self, testsetup):
     """
     Litmus 25730
     https://litmus.mozilla.org/show_test.cgi?id=25730
     """
     amo_details_page = AddonsDetailsPage(testsetup, "Firebug")
     amo_details_page.click_report_abuse_link()
     Assert.true(amo_details_page.is_report_abuse_send_report_button_visible())
     Assert.equal(amo_details_page.report_abuse_send_report_button, "Send Report")
    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_icon_locator(self, testsetup):  #broken in impala
     #Firebug icon
     #image_url = "https://static-cdn.addons.mozilla.net/en-US/firefox/images/addon_icon/1843-32.png?modified=1300780225"
     #Tab Mix Plus icon
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     image_url = "https://gs1.adn.edgecastcdn.net/801237/addons-cdn.allizom.org/en-US/firefox/images/addon_icon/1122-32.png?modified=1305054615"  #?modified=1305054615"
     Assert.true(
         tab_mix_plus_page.is_element_present("css=input[type=img], [src=" +
                                              image_url + "]"))
 def test_that_external_link_leads_to_addon_website(self, testsetup):
     """ Litmus 11809
         https://litmus.mozilla.org/show_test.cgi?id=11809 """
     # Step 1 - Open AMO homepage
     # Step 2 - Open Adblock Plus details page
     details_page = AddonsDetailsPage(testsetup, 'Adblock Plus')
     website_link = details_page.website
     Assert.true(website_link != '')
     # Step 3 - Follow external website link
     details_page.click_website_link()
     Assert.true(website_link in details_page.get_url_current_page())
    def test_that_review_usernames_are_clickable(self, testsetup):
        """
        Litmus 4842
        https://litmus.mozilla.org/show_test.cgi?id=4842
        """
        addon_name = 'firebug'
        amo_detail_page = AddonsDetailsPage(testsetup, addon_name)

        for review in amo_detail_page.reviews():
            username = review.username
            amo_user_page = review.click_username()
            Assert.equal(username, amo_user_page.username)
            AddonsDetailsPage(testsetup, addon_name)
    def test_navigating_to_other_addons_by_the_same_author_when_there_are_more_than_four_other_addons(self, testsetup):
        """
        Litmus 11926
        https://litmus.mozilla.org/show_test.cgi?id=1192"""
        addon_with_more_than_four_addons_by_the_same_author = 'firebug'
        amo_detail_page = AddonsDetailsPage(testsetup, addon_with_more_than_four_addons_by_the_same_author)

        addons = amo_detail_page.other_addons_dropdown_values
        Assert.true(len(addons) > 4)
        for i in range(len(addons) - 1, 0, -1):  # Not checking the first item in the drop-down https://bugzilla.mozilla.org/show_bug.cgi?id=660706
            amo_detail_page.select_other_addons_dropdown_value(addons[i])
            print addons[i]
            Assert.true(amo_detail_page.name.startswith(addons[i].rstrip('.')))
            AddonsDetailsPage(testsetup, addon_with_more_than_four_addons_by_the_same_author)
    def test_navigating_to_other_addons_by_the_same_author_when_there_are_less_than_five_other_addons(self, testsetup):
        """
        Litmus 11926
        https://litmus.mozilla.org/show_test.cgi?id=1192"""
        addon_with_less_than_five_addons_by_the_same_author = 'adblock-plus'
        amo_detail_page = AddonsDetailsPage(testsetup, addon_with_less_than_five_addons_by_the_same_author)

        addons = amo_detail_page.other_addons_link_list()
        Assert.true(len(addons) < 5)
        for i in range(amo_detail_page.other_addons_link_list_count):
            amo_detail_page.click_other_addon_by_this_author(addons[i])
            print addons[i]
            Assert.true(amo_detail_page.name.startswith(addons[i].rstrip('.')))
            AddonsDetailsPage(testsetup, addon_with_less_than_five_addons_by_the_same_author)
    def test_details_more_images(self, testsetup):
        """
        Litmus 4846
        https://litmus.mozilla.org/show_test.cgi?id=4846
        """
        amo_detail_page = AddonsDetailsPage(testsetup, 'firebug')

        image_viewer = amo_detail_page.click_addon_image()
        Assert.true(image_viewer.is_visible)
        image_viewer.close()
        Assert.false(image_viewer.is_visible)

        additional_images_count = amo_detail_page.additional_images_count
        for i in range(1, additional_images_count):
            image_viewer = amo_detail_page.click_additional_image(i)
            Assert.equal(i + 1, image_viewer.current_image)
            Assert.true(image_viewer.is_visible)
            image_viewer.close()
            Assert.false(image_viewer.is_visible)

        image_viewer = amo_detail_page.click_additional_image(1)
        Assert.true(image_viewer.is_visible)

        for i in range(2, image_viewer.total_images_count + 1):
            Assert.true(image_viewer.is_visible)
            Assert.equal(i, image_viewer.current_image)
            Assert.true(image_viewer.is_close_visible)
            Assert.equal("Image %s of %s" % (i, additional_images_count + 1), image_viewer.current_number)
            if not i == image_viewer.total_images_count:
                image_viewer.click_next()

        Assert.false(image_viewer.is_next_link_visible)
        Assert.true(image_viewer.is_previous_link_visible)

        for i in range(image_viewer.total_images_count, 0, -1):
            Assert.true(image_viewer.is_visible)
            Assert.equal(i, image_viewer.current_image)
            Assert.true(image_viewer.is_close_visible)
            Assert.equal("Image %s of %s" % (i, additional_images_count + 1), image_viewer.current_number)
            if not i == 1:
                image_viewer.click_previous()

        Assert.true(image_viewer.is_next_link_visible)
        Assert.false(image_viewer.is_previous_link_visible)

        image_viewer.close()
        Assert.false(image_viewer.is_visible)
    def test_get_author_children_locators(self, testsetup): #ok in impala      
        tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
        i = 1
        author_list = [ tab_mix_plus_page.get_text("//h4[@class='author']/a[%i]" % (i+1)) 
            for i in range(tab_mix_plus_page.selenium.get_xpath_count("//h4[@class='author']/a")) ]

        #These tests are for Firebug data
        #Assert.equal(5, len(author_locator))
        #Assert.equal("Joe Hewitt",self.selenium.get_text("//h4[@class='author']/a[1]"))
        #Assert.equal("johnjbarton",self.selenium.get_text("//h4[@class='author']/a[2]"))
        #Assert.equal("robcee",self.selenium.get_text("//h4[@class='author']/a[3]"))
        #Assert.equal("FirebugWorkingGroup",self.selenium.get_text("//h4[@class='author']/a[4]"))
        #Assert.equal("Jan Odvarko",self.selenium.get_text("//h4[@class='author']/a[5]"))
        
        #These tests are for 
        Assert.equal(2, len(author_list))
        Assert.equal("onemen",author_list[0])
        Assert.equal("Gary Reyes",author_list[1])
    def test_get_author_children_locators(self, testsetup):  #ok in impala
        tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
        i = 1
        author_list = [
            tab_mix_plus_page.get_text("//h4[@class='author']/a[%i]" % (i + 1))
            for i in range(
                tab_mix_plus_page.selenium.get_xpath_count(
                    "//h4[@class='author']/a"))
        ]

        #These tests are for Firebug data
        #Assert.equal(5, len(author_locator))
        #Assert.equal("Joe Hewitt",self.selenium.get_text("//h4[@class='author']/a[1]"))
        #Assert.equal("johnjbarton",self.selenium.get_text("//h4[@class='author']/a[2]"))
        #Assert.equal("robcee",self.selenium.get_text("//h4[@class='author']/a[3]"))
        #Assert.equal("FirebugWorkingGroup",self.selenium.get_text("//h4[@class='author']/a[4]"))
        #Assert.equal("Jan Odvarko",self.selenium.get_text("//h4[@class='author']/a[5]"))

        #These tests are for
        Assert.equal(2, len(author_list))
        Assert.equal("onemen", author_list[0])
        Assert.equal("Gary Reyes", author_list[1])
 def test_that_whats_this_link_for_source_license_links_to_an_answer_in_faq(self, testsetup):
     """ Test for Litmus 11530"""
     amo_details_page = AddonsDetailsPage(testsetup, "Firebug")
     user_faq_page = amo_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_install_locator(self, testsetup):    
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus") 
     Assert.true(tab_mix_plus_page.is_element_present("css=p[class='install-button'] > a"))
    def test_that_all_reviews_hyperlink_works(self, mozwebqa):
        """ Test for litmus 4843
            https://litmus.mozilla.org/show_test.cgi?id=4843
        """
        #Open details page for Adblock Plus
        amo_details_page = AddonsDetailsPage(mozwebqa, 'Adblock Plus')
        Assert.true(amo_details_page.has_reviews)

        amo_details_page.click_all_reviews_link()
        Assert.equal(amo_details_page.review_count, 20)

        #Go to the last page and check that the next button is not present
        amo_details_page.go_to_last_page()
        Assert.false(amo_details_page.is_next_link_present)

        #Go one page back, check that it has 20 reviews
        #that the page number decreases and that the next link is visible
        page_number = amo_details_page.current_page
        amo_details_page.page_back()
        Assert.true(amo_details_page.is_next_link_visible)
        Assert.equal(amo_details_page.review_count, 20)
        Assert.equal(amo_details_page.current_page, page_number - 1)

        #Go to the first page and check that the prev button is not present
        amo_details_page.go_to_first_page()
        Assert.false(amo_details_page.is_prev_link_present)

        #Go one page forward, check that it has 20 reviews,
        #that the page number increases and that the prev link is visible
        page_number = amo_details_page.current_page
        amo_details_page.page_forward()
        Assert.true(amo_details_page.is_prev_link_visible)
        Assert.equal(amo_details_page.review_count, 20)
        Assert.equal(amo_details_page.current_page, page_number + 1)
 def test_contribute_locator(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(
         tab_mix_plus_page.is_element_present(
             "css=a[id='contribute-button']"))
 def test_ratings_locator(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(
         tab_mix_plus_page.is_element_present(
             "css=span[itemprop='rating']"))
 def test_first_author_name(self, testsetup): #ok in impala
     #Firebug test
     #Assert.equal("Joe Hewitt",self.selenium.get_text("//h4[@class='author']/a[1]"))
     #Tab Mix Plus test
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.equal("onemen",tab_mix_plus_page.get_text("//h4[@class='author']/a[1]"))
 def test_addon_id_locator(self, testsetup): #ok in impala
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(tab_mix_plus_page.is_element_present("//div[@data-id='1122']"))
 def test_that_about_this_addon_is_displayed(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.is_about_addon_visible())
     Assert.equal(amo_details_page.about_addon, "About this Add-on")
     Assert.not_none(re.match('(\w+\s*){3,}', amo_details_page.description))
 def test_that_summary_is_displayed(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.is_summary_visible())
     # check that the summary is not empty
     Assert.not_none(re.match('(\w+\s*){3,}', amo_details_page.summary))
 def test_that_addon_name_is_displayed(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.is_addon_name_visible())
     # check that the name is not empty
     Assert.not_equal(amo_details_page.name, "")
 def test_that_dropdown_menu_is_present_after_click_on_other_apps(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.is_other_apps_link_visible())
     Assert.equal(amo_details_page.other_apps, "Other Applications")
 def test_that_login_link_is_present_in_addon_details_page(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.is_login_visible())
     Assert.equal(amo_details_page.login_link, "Log in")
 def test_part_of_collections_are_displayed(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.is_part_of_collections_header_visible())
     Assert.true(amo_details_page.is_part_of_collections_list_visible())
     Assert.equal(amo_details_page.part_of_collections_header, 'Part of these Collections')
 def test_that_tags_are_displayed(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.are_tags_visible())
 def test_author_group_locator(self, testsetup):  #ok in impala
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(
         tab_mix_plus_page.is_element_present("//h4[@class='author']/a"))
 def test_author_group_locator(self, testsetup): #ok in impala
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(tab_mix_plus_page.is_element_present("//h4[@class='author']/a"))
 def test_that_details_page_object_opens_the_right_page(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(len(str(tab_mix_plus_page.page_title)) > 0)
 def test_details_page_object_version_number(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(len(str(tab_mix_plus_page.version_number)) > 0)
 def test_version_number_locator(self, testsetup):   #ok in impala 
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(tab_mix_plus_page.is_element_present("css=span.version"))       
 def test_summary_locator(self, testsetup): 
     #This was written as the details page was being upgraded, thus 2 locators.
     new_impala_summary_locator = "css=p[id=addon-summary]"
     old_zamboni_summary_locator = "css=div[id=addon-summary]>p"
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(tab_mix_plus_page.is_element_present(old_zamboni_summary_locator))
 def test_install_locator(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(
         tab_mix_plus_page.is_element_present(
             "css=p[class='install-button'] > a"))
 def test_details_page_object_summary(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     summary = "Tab Mix Plus enhances Firefox's tab browsing capabilities. It includes such features as duplicating tabs, controlling tab focus, tab clicking options, undo closed tabs and windows, plus much more. It also includes a full-featured session manager."
     Assert.equal(summary, tab_mix_plus_page.summary)
 def test_that_details_object_has_selenium(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.equal("<class 'selenium.selenium.selenium'>",
                  str(type(tab_mix_plus_page.selenium)))
 def test_addon_rating(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.equal("4", tab_mix_plus_page.rating)
 def test_contribute_locator(self, testsetup): 
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus") 
     Assert.true(tab_mix_plus_page.is_element_present("css=a[id='contribute-button']"))
 def test_version_number_locator(self, testsetup):  #ok in impala
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(tab_mix_plus_page.is_element_present("css=span.version"))
 def test_ratings_locator(self, testsetup): 
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(tab_mix_plus_page.is_element_present("css=span[itemprop='rating']"))
 def test_addon_id_locator(self, testsetup):  #ok in impala
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     Assert.true(
         tab_mix_plus_page.is_element_present("//div[@data-id='1122']"))
 def test_details_page_object_authors(self, testsetup):
     tab_mix_plus_page = AddonsDetailsPage(testsetup, "Tab Mix Plus")
     authors = tab_mix_plus_page.authors
     Assert.equal("onemen", authors[0])
     Assert.equal("Gary Reyes", authors[1])
 def test_that_in_often_used_with_addons_are_displayed(self, mozwebqa):
     """ Test for Litmus 9890"""
     amo_details_page = AddonsDetailsPage(mozwebqa, "Firebug")
     Assert.true(amo_details_page.is_often_used_with_header_visible())
     Assert.equal(amo_details_page.often_used_with_header, u"Often used with\u2026")
     Assert.true(amo_details_page.is_often_used_with_list_visible())