Closed Bug 612938 Opened 14 years ago Closed 14 years ago

Socorro Selenium Tests

Categories

(Testing Graveyard :: WebQA, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: automatedtester, Unassigned)

References

()

Details

Attachments

(1 file, 2 obsolete files)

Attached file Socorro Selenium Tests (obsolete) —
      No description provided.
Attached patch Socorro Selenium Tests (obsolete) — Splinter Review
added another test case
Attachment #491260 - Attachment is obsolete: true
Attachment #491283 - Flags: review?(vish.mozilla)
Attachment #491283 - Flags: review?(tgavankar)
Attachment #491283 - Flags: review?(stephen.donner)
Attachment #491283 - Flags: feedback?(robert)
Attachment #491283 - Flags: feedback?(laura)
Attachment #491283 - Flags: review?(stephen.donner) → review?
Attachment #491283 - Flags: feedback?(stephen.donner)
Comment on attachment 491283 [details] [diff] [review]
Socorro Selenium Tests

Awesome! Very Readable. I liked the idea of using _variable_name for suggesting private variables and using @property.
The values for instantiating a selenium object should be in a separate file like we have for SUMO:
http://viewvc.svn.mozilla.org/vc/projects/sumo/tests/frontend/python_tests/vars.py

Other than that everything else looks good.
Attachment #491283 - Flags: review?(vish.mozilla) → review+
updated after comments from review
Attachment #491283 - Attachment is obsolete: true
Attachment #491283 - Flags: review?(tgavankar)
Attachment #491283 - Flags: review?
Attachment #491283 - Flags: feedback?(stephen.donner)
Attachment #491283 - Flags: feedback?(robert)
Attachment #491283 - Flags: feedback?(laura)
Attachment #491531 - Flags: review?(vish.mozilla)
Attachment #491531 - Flags: review?(tgavankar)
Attachment #491531 - Flags: feedback?(stephen.donner)
Attachment #491531 - Flags: feedback?(robert)
Attachment #491531 - Flags: feedback?(laura)
Comment on attachment 491531 [details] [diff] [review]
Socorro Selenium Tests

>Index: crash_stats_page.py
>===================================================================
>--- crash_stats_page.py	(revision 0)
>+++ crash_stats_page.py	(revision 0)
>@@ -0,0 +1,380 @@
>+#!/usr/bin/env python
>+
>+'''
>+Created October, 2010
>+
>+@author: Mozilla
>+'''
>+
>+from selenium import selenium
>+import re
>+import time
>+import base64
>+from page import Page
>+from vars import ConnectionParameters
>+
>+
>+class CrashStatsBasePage(Page):
>+
>+    _page_heading = 'css=div.page-heading > h2'
>+
>+    def __init__(self, selenium):
>+        self.sel = selenium
>+
>+    @property
>+    def page_title(self):
>+        return self.sel.get_title()
>+
>+    @property
>+    def page_heading(self):
>+        return self.sel.get_text(self._page_heading)
>+
>+    def get_attribute(self, element, attribute):
>+        return self.sel.get_attribute(element + '@' + attribute)
>+
>+    def get_url_path(self, path):
>+        self.sel.open(path)
>+
>+    def select_product(self, application):
>+        '''
>+            Select the Mozilla Product you want to report on
>+        '''
>+        self.sel.select(self._product_select, application)
>+        self.sel.wait_for_page_to_load('30000')
>+
>+    def select_version(self, version):
>+        '''
>+            Select the version of the application you want to report on
>+        '''
>+        self.sel.select(self._product_version_select, version)
>+        self.sel.wait_for_page_to_load('30000')
>+
>+    def select_report(self, report_name):
>+        '''
>+            Select the report type from the drop down
>+            and wait for the page to reload
>+        '''
>+        self.sel.select(self._report_select, report_name)
>+        self.sel.wait_for_page_to_load('30000')
>+        if 'Top Crashers' == report_name:
>+            return CrashStatsTopCrashers(self.sel)
>+        elif 'Top Crashers by Domain' == report_name:
>+            return CrashStatsTopCrashersByDomain(self.sel)
>+        elif 'Top Crashers by URL' == report_name:
>+            return CrashStatsTopCrashersByUrl(self.sel)
>+        elif 'Top Crashers by TopSite' == report_name:
>+            return CrashStatsTopCrashersBySite(self.sel)
>+        elif 'Crashes per User' == report_name:
>+            return CrashStatsPerActiveDailyUser(self.sel)
>+
>+    def click_server_status(self):
>+        self.sel.click('link=Server Status')
>+        self.sel.wait_for_page_to_load('30000')
>+        return CrashStatsStatus(self.sel)
>+
>+    def click_advanced_search(self):
>+        self.sel.click('link=Advanced Search')
>+        return CrashStatsAdvancedSearch(self.sel)
>+
>+    def can_find_text(self, text_to_search):
>+        '''
>+            finds if text is available on a page.
>+        '''
>+        return self.sel.is_text_present(text_to_search)
>+
>+    def wait_for_element_present(self, element):
>+        count = 0
>+        while not self.sel.is_element_present(element):
>+            time.sleep(1)
>+            count += 1
>+            if count == 20:
>+                self.record_error()
>+                raise Exception(element + ' has not loaded')
>+
>+    def wait_for_element_visible(self, element):
>+        self.wait_for_element_present(element)
>+        count = 0
>+        while not self.sel.is_visible(element):
>+            time.sleep(1)
>+            count += 1
>+            if count == 20:
>+                self.record_error()
>+                raise Exception(element + " is still visible")
>+
>+    @property
>+    def current_details(self):
>+        details = {}
>+        details['product'] = self.sel.get_selected_value(self._product_select)
>+        try:
>+            details['versions'] = self.sel.get_text(
>+                'xpath=//select[@id="product_version_select"]/optgroup[2]').split(' ')
>+        except:
>+            details['versions'] = []
>+        return details
>+
>+    def record_error(self):
>+        '''
>+
>+        '''
>+        print '-------------------'
>+        print 'Error at ' + self.sel.get_location()
>+        print 'Page title ' + self.sel.get_title()
>+        print '-------------------'
>+        filename = 'socorro_' + str(time.time()).split('.')[0] + '.png'
>+
>+        print 'Screenshot of error in file ' + filename
>+        f = open(filename, 'wb')
>+        f.write(base64.decodestring(
>+            self.sel.capture_entire_page_screenshot_to_string('')))
>+        f.close()
>+
>+
>+class CrashStatsHomePage(CrashStatsBasePage):
>+    '''
>+        Page Object for Socorro
>+    '''
>+    _find_crash_id_or_signature = 'id=q'
>+    _product_select = 'id=products_select'
>+    _product_version_select = 'id=product_version_select'
>+    _report_select = 'id=report_select'
>+    _first_signature_locator = 'css=div.crash > p > a'
>+    _right_column_locator = 'css=div.product_topcrasher > h4'
>+    _centre_column_locator = 'css=div.product_topcrasher + div > h4'
>+    _left_column_locator = 'css=div.product_topcrasher + div + div > h4'
>+    _top_crashers = 'css=a:contains("Top Crashers")'
>+    _top_changers = 'css=a:contains("Top Changers")'
>+    _top_crashers_selected = _top_crashers + '.selected'
>+    _top_changers_selected = _top_changers + '.selected'
>+
>+
>+    def __init__(self, selenium):
>+        '''
>+            Creates a new instance of the class and gets the page ready for testing
>+        '''
>+        super(CrashStatsHomePage, self).__init__(selenium)
>+        self.sel = selenium
>+        self.sel.open('/')
>+        count = 0
>+        while not re.search(r'http?\w://.*/products/.*', self.sel.get_location(), re.U):
>+            time.sleep(1)
>+            count += 1
>+            if count == 20:
>+                self.record_error()
>+                raise Exception("Home Page has not loaded")
>+
>+        if not self.sel.get_title() == 'Crash Data for Mozilla Firefox':
>+            self.sel.select(self.product_select, 'Firefox')
>+            self.sel.wait_for_page_to_load('30000')
>+        self.sel.window_maximize()
>+
>+    def report_length(self, days):
>+        '''
>+            Click on the link with the amount of days you want the report to be
>+        '''
>+        self.sel.click('link=' + days + ' days')
>+        self.sel.wait_for_page_to_load("30000")
>+        self.wait_for_element_present('xpath=//a[text()="'
>+                                                + days + ' days" and @class="selected"]')
>+
>+    def search_for_crash(self, crash_id_or_signature):
>+        '''
>+            Type the signature or the id of a bug into the search bar and submit the form
>+        '''
>+        self.sel.type(self._find_crash_id_or_signature, crash_id_or_signature)
>+        self.sel.key_press(self._find_crash_id_or_signature, "\\13")
>+        #self.sel.submit('//form')
>+        self.sel.wait_for_page_to_load('30000')
>+        return CrashStatsSearchResults(self.sel)

Should we perhaps be splitting up testing searching by crash-report ID or signature?

>+
>+    def click_on_top_(self, element):
>+        topElement = 'link=Top ' + element
>+        self.sel.click(topElement)
>+        if element == 'Changers':
>+            self.wait_for_element_visible(self._top_changers_selected)
>+        else:
>+            self.wait_for_element_visible(self._top_crashers_selected)
>+
>+    @property
>+    def get_product_list(self):
>+        return self.sel.get_select_options(self._product_select)
>+
>+    @property
>+    def first_signature(self):
>+        '''
>+
>+        '''
>+        return self.sel.get_text(self._first_signature_locator)
>+
>+    @property
>+    def right_column_heading(self):
>+        return self.sel.get_text(self._right_column_locator)[:-9]
>+
>+    @property
>+    def centre_column_heading(self):
>+        return self.sel.get_text(self._centre_column_locator)[:-9]
>+
>+    @property
>+    def left_column_heading(self):
>+        return self.sel.get_text(self._left_column_locator)[:-9]
>+
>+
>+class CrashStatsAdvancedSearch(CrashStatsBasePage):
>+
>+    _product_multiple_select = 'id=product'
>+    _filter_crash_reports_button = 'id=query_submit'
>+    _data_table = 'id=signatureList'
>+    _data_table_first_signature = 'css=table#signatureList > tbody > tr > td > a'
>+
>+    def __init__(self, selenium):
>+        '''
>+            Creates a new instance of the class and gets the page ready for testing
>+        '''
>+        super(CrashStatsAdvancedSearch, self).__init__(selenium)
>+        self.sel = selenium
>+        count = 0
>+        self.wait_for_element_present(self._product_multiple_select)
>+
>+    def filter_reports(self):
>+        self.sel.click(self._filter_crash_reports_button)
>+        self.wait_for_element_present('css=div.page-heading h2:contains("Query Results")')
>+
>+    def click_first_signature(self):
>+        self.wait_for_element_present(self._data_table_first_signature)
>+        signature = self.sel.get_text(self._data_table_first_signature)
>+        self.sel.click(self._data_table_first_signature)
>+        self.sel.wait_for_page_to_load('30000')
>+        return signature
>+
>+    @property
>+    def currently_selected_product(self):
>+        return self.sel.get_selected_value(self._product_multiple_select)
>+
>+    @property
>+    def product_list(self):
>+        return self.sel.get_select_options(self._product_multiple_select)
>+
>+
>+class CrashStatsSearchResults(CrashStatsBasePage):
>+
>+    _product_select = 'id=product'
>+    _version_select = 'id=version'
>+    _os_select = 'id=platform'
>+    _filter_crash_reports_button = 'id=query_submit'
>+
>+    def __init__(self, selenium):
>+        super(CrashStatsSearchResults, self).__init__(selenium)
>+        self.sel = selenium
>+        self.wait_for_element_present(self._product_select)
>+
>+
>+class CrashStatsPerActiveDailyUser(CrashStatsBasePage):
>+
>+    _product_select = 'id=daily_search_version_form_products'
>+
>+    def __init__(self, selenium):
>+        '''
>+            Creates a new instance of the class and gets the page ready for testing
>+        '''
>+        super(CrashStatsPerActiveDailyUser, self).__init__(selenium)
>+        self.sel = selenium
>+
>+    @property
>+    def product_select(self):
>+        return self.sel.get_selected_value(self._product_select)
>+
>+
>+class CrashStatsTopCrashers(CrashStatsBasePage):
>+
>+    _product_header = 'css=h2 > span.current-product'
>+    _product_version_header = 'css=h2 > span.current-version'
>+
>+    def __init__(self, selenium):
>+        super(CrashStatsTopCrashers, self).__init__(selenium)
>+        self.sel = selenium
>+
>+    @property
>+    def product_header(self):
>+        return self.sel.get_text(self._product_header)
>+
>+    @property
>+    def product_version_header(self):
>+        return self.sel.get_text(self._product_version_header)
>+
>+
>+class CrashStatsTopCrashersByUrl(CrashStatsBasePage):
>+
>+    _product_header = 'id=tcburl-product'
>+    _product_version_header = 'id=tcburl-version'
>+
>+    def __init__(self, selenium):
>+        super(CrashStatsTopCrashersByUrl, self).__init__(selenium)
>+        self.sel = selenium
>+
>+    @property
>+    def product_header(self):
>+        return self.sel.get_text(self._product_header)
>+
>+    @property
>+    def product_version_header(self):
>+        return self.sel.get_text(self._product_version_header)
>+
>+
>+class CrashStatsTopCrashersByDomain(CrashStatsBasePage):
>+
>+    _product_header = 'id=tcburl-product'
>+    _product_version_header = 'id=tcburl-version'
>+
>+    def __init__(self, selenium):
>+        super(CrashStatsTopCrashersByDomain, self).__init__(selenium)
>+        self.sel = selenium
>+
>+    @property
>+    def product_header(self):
>+        return self.sel.get_text(self._product_header)
>+
>+    @property
>+    def product_version_header(self):
>+        return self.sel.get_text(self._product_version_header)
>+
>+
>+class CrashStatsTopCrashersBySite(CrashStatsBasePage):
>+
>+    _product_header = 'id=tcburl-product'
>+    _product_version_header = 'id=tcburl-version'
>+
>+    def __init__(self, selenium):
>+        super(CrashStatsTopCrashersBySite, self).__init__(selenium)
>+        self.sel = selenium
>+
>+    @property
>+    def product_header(self):
>+        return self.sel.get_text(self._product_header)
>+
>+    @property
>+    def product_version_header(self):
>+        return self.sel.get_text(self._product_version_header)
>+
>+
>+class CrashStatsStatus(CrashStatsBasePage):
>+
>+    _page_header = 'css=h2:contains("Server Status")'
>+    _at_a_glance_locator = 'css=div.title:contains("At a Glance")'
>+    _graphs_locator = 'css=div.title:contains("Graphs")'
>+    _latest_raw_stats = 'css=div.title:contains("Latest Raw Stats")'
>+
>+    def __init__(self, selenium):
>+        super(CrashStatsStatus, self).__init__(selenium)
>+        self.sel = selenium
>+        self.wait_for_element_present(self._page_header)
>+
>+    def at_a_glance(self):
>+        if not self.sel.is_element_present(self._at_a_glance_locator):
>+            raise Exception(self._at_a_glance_locator + ' is not available')
>+
>+    def graphs(self):
>+        if not self.sel.is_element_present(self._graphs_locator):
>+            raise Exception(self._graphs_locator + ' is not available')
>+
>+    def latest_raw_stats(self):
>+        if not self.sel.is_element_present(self._graphs_locator):
>+            raise Exception(self._latest_raw_stats + ' is not available')
>Index: vars.py
>===================================================================
>--- vars.py	(revision 0)
>+++ vars.py	(revision 0)
>@@ -0,0 +1,29 @@
>+class ConnectionParameters:
>+    server = 'localhost' #"qa-selenium.mv.mozilla.com"
>+    port = 4444
>+    browser = "*firefox" #"Firefox-default-b;en-us;MacOSX6"
>+    #browser = "*iexplore"
>+    baseurl = "http://crash-stats.stage.mozilla.com"
>+    authurl = "http://crash-stats.stage.mozilla.com"
>+    page_load_timeout = 120000
>+
>+class ConfigOptions:
>+    #Environment list
>+    Smoketests = [
>+    #"Firefox-default;en-us;Vista"
>+    "Firefox-default-b;en-us;MacOSX6"
>+    ]
>+    
>+    BFT = [
>+    #"IE-8;en-us;Vista"
>+    ]
>+    BFT.extend(Smoketests)
>+    
>+    FFT = [
>+    "Firefox-3.5;en-us;MacOSX6",
>+    "Safari;en-us;MacOSX6",
>+    "Firefox-3.5;en-us;WinXP",
>+    #"Firefox-default-b;en-us;MacOSX6",
>+    #"IE-7;en-us;WinXP"
>+    ]
>+    FFT.extend(BFT)
>Index: page.py
>===================================================================
>--- page.py	(revision 0)
>+++ page.py	(revision 0)
>@@ -0,0 +1,57 @@
>+'''
>+Created on Jun 21, 2010
>+
>+@author: mozilla
>+'''
>+import re
>+
>+
>+
>+class Page(object):
>+    '''
>+    Base class for all Pages
>+    '''
>+
>+        
>+    def __init__(self, selenium):
>+        '''
>+        Constructor
>+        '''
>+        self.selenium = selenium
>+        
>+        
>+    def verify_page_title(self, title_regexp):
>+        if (re.search(title_regexp, self.selenium.get_title()) is None):
>+            raise Exception,'\r\nPage tile verification failed. Expected: %s; Actual:%s\r\n' %(title_regexp,self.selenium.get_title())

Nit: "title"

>+       
>+        
>+    def click_link(self, link, wait_flag=False,timeout=80000):
>+        self.selenium.click("link=%s" %(link))
>+        if(wait_flag):
>+            self.selenium.wait_for_page_to_load(timeout)
>+        
>+    def click(self,locator,wait_flag=False,timeout=80000):
>+        self.selenium.click(locator)
>+        if(wait_flag):
>+            self.selenium.wait_for_page_to_load(timeout)
>+            
>+    def type(self,locator, str):
>+        self.selenium.type(locator, str)
>+        
>+    def click_button(self,button,wait_flag=False,timeout=80000):
>+        self.selenium.click(button)
>+        if(wait_flag):
>+            self.selenium.wait_for_page_to_load(timeout)
>+
>+    def get_url_current_page(self):
>+        return(self.selenium.get_location())
>+    
>+    def is_element_present(self,locator):
>+        return self.selenium.is_element_present(locator)
>+    
>+    def is_text_present(self,text):
>+        return self.selenium.is_text_present(text)
>+    
>+    def refresh(self,timeout=80000):
>+        self.selenium.refresh()
>+        self.selenium.wait_for_page_to_load(timeout)
>\ No newline at end of file

Please fix this before check-in

>Index: test_specific_versions.py
>===================================================================
>--- test_specific_versions.py	(revision 0)
>+++ test_specific_versions.py	(revision 0)
>@@ -0,0 +1,43 @@
>+#!/usr/bin/env python
>+import unittest
>+from selenium import selenium
>+from crash_stats_page import CrashStatsHomePage
>+from crash_stats_page import CrashStatsSearchResults
>+from vars import ConnectionParameters
>+
>+
>+class TestSpecificVersions(unittest.TestCase):
>+
>+    def setUp(self):
>+        self.selenium = selenium(ConnectionParameters.server, ConnectionParameters.port,
>+                    ConnectionParameters.browser, ConnectionParameters.baseurl)
>+        self.selenium.start()
>+
>+    def tearDown(self):
>+        self.selenium.stop()
>+
>+    def test_that_selecting_exact_version_doesnt_show_other_versions(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        details = csp.current_details
>+        if len(details['versions']) > 0:
>+            csp.select_version(details['versions'][1])
>+        
>+        self.assertEqual(details['product'] + ' ' + details['versions'][1],csp.right_column_heading)
>+
>+        try:
>+            centre_name = csp.centre_column_heading
>+            self.fail(centre_name + ' was shown when it shouldnt be there')

nit: "shouldn't"

>+        except Exception, e:
>+            pass
>+
>+        try:
>+            right_name = csp.right_column_heading
>+            self.fail(right_name + ' was shown when it shouldnt be there')

ditto nit: "shouldn't"

>+        except Exception, e:
>+            pass
>+
>+
>+
>+
>+if __name__ == "__main__":
>+    unittest.main()
>Index: test_crash_reports.py
>===================================================================
>--- test_crash_reports.py	(revision 0)
>+++ test_crash_reports.py	(revision 0)
>@@ -0,0 +1,191 @@
>+#!/usr/bin/env python
>+import unittest
>+from selenium import selenium
>+from crash_stats_page import CrashStatsHomePage
>+from crash_stats_page import CrashStatsSearchResults
>+from crash_stats_page import CrashStatsPerActiveDailyUser
>+from vars import ConnectionParameters
>+
>+class TestCrashReports(unittest.TestCase):
>+
>+    def setUp(self):
>+        self.selenium = selenium(ConnectionParameters.server, ConnectionParameters.port,
>+                    ConnectionParameters.browser, ConnectionParameters.baseurl)
>+        self.selenium.start()
>+
>+    def tearDown(self):
>+        self.selenium.stop()
>+    
>+    def test_that_reports_form_has_same_product_for_firefox(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        crash_adu = csp.select_report("Crashes per User")
>+        page_title = csp.page_title
>+        self.assertTrue('Firefox' in page_title)
>+        self.assertTrue('Mozilla' in page_title)
>+        details = csp.current_details
>+        report_product = crash_adu.product_select
>+        self.assertEqual(details['product'],report_product)
>+
>+    def test_that_reports_form_has_same_product_for_thunderbird(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        page_title = csp.page_title
>+        self.assertTrue('Thunderbird' in page_title)
>+        self.assertTrue('Mozilla' in page_title)
>+        crash_adu = csp.select_report("Crashes per User")
>+        details = csp.current_details
>+        report_product = crash_adu.product_select
>+        self.assertEqual(details['product'],report_product)
>+
>+    def test_that_reports_form_has_same_product_for_seamonkey(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        page_title = csp.page_title
>+        self.assertTrue('SeaMonkey' in page_title)
>+        self.assertTrue('Mozilla' not in page_title)
>+        crash_adu = csp.select_report("Crashes per User")
>+        details = csp.current_details
>+        report_product = crash_adu.product_select
>+        self.assertEqual(details['product'],report_product)
>+
>+    def test_that_reports_form_has_same_product_for_camino(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        page_title = csp.page_title
>+        self.assertTrue('Camino' in page_title)
>+        self.assertTrue('Mozilla' not in page_title)
>+        crash_adu = csp.select_report("Crashes per User")
>+        details = csp.current_details
>+        report_product = crash_adu.product_select
>+        self.assertEqual(details['product'],report_product)
>+
>+    def test_that_reports_form_has_same_product_for_fennec(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        page_title = csp.page_title
>+        self.assertTrue('Fennec' in page_title)
>+        self.assertTrue('Mozilla' not in page_title)
>+        crash_adu = csp.select_report("Crashes per User")
>+        details = csp.current_details
>+        report_product = crash_adu.product_select
>+        self.assertEqual(details['product'],report_product)
>+
>+    def test_that_current_version_selected_in_top_crashers_header_for_firefox(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+    
>+    def test_that_current_version_selected_in_top_crashers_header_for_thunderbird(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_header_for_seamonkey(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_header_for_camino(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_header_for_fennec(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_url_header_for_firefox(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by URL')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+    
>+    def test_that_current_version_selected_in_top_crashers_by_url_header_for_thunderbird(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by URL')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_url_header_for_seamonkey(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by URL')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_url_header_for_camino(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by URL')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_url_header_for_fennec(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by URL')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_domain_header_for_firefox(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by Domain')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+    
>+    def test_that_current_version_selected_in_top_crashers_by_domain_header_for_thunderbird(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by Domain')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_domain_header_for_seamonkey(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by Domain')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_domain_header_for_camino(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by Domain')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+    def test_that_current_version_selected_in_top_crashers_by_domain_header_for_fennec(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        details = csp.current_details
>+        cstc = csp.select_report('Top Crashers by Domain')
>+        self.assertEqual(details['product'], cstc.product_header)
>+        self.assertTrue(cstc.product_version_header in details['versions'])
>+
>+if __name__ == "__main__":
>+    unittest.main()
>Index: test_smoke_tests.py
>===================================================================
>--- test_smoke_tests.py	(revision 0)
>+++ test_smoke_tests.py	(revision 0)
>@@ -0,0 +1,284 @@
>+#!/usr/bin/env python
>+import unittest
>+from selenium import selenium
>+from crash_stats_page import CrashStatsHomePage
>+from crash_stats_page import CrashStatsSearchResults
>+from vars import ConnectionParameters
>+
>+class TestSmokeTests(unittest.TestCase):
>+
>+    def setUp(self):
>+        self.selenium = selenium(ConnectionParameters.server, ConnectionParameters.port,
>+                    ConnectionParameters.browser, ConnectionParameters.baseurl)
>+        self.selenium.start()
>+
>+    def tearDown(self):
>+        self.selenium.stop()
>+
>+    def test_that_option_group_matches_visible_columns_for_firefox(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        self.assertTrue('Firefox' in csp.page_title)
>+        details = csp.current_details
>+        headers = []
>+        for i in details['versions']:
>+            headers.append(details['product'] + ' ' + i)
>+
>+        if len(headers) > 0:
>+            self.assertEqual(headers[0], csp.right_column_heading)
>+        
>+            #Check the centre column
>+            centre = ''
>+            try:
>+                centre = csp.centre_column_heading
>+            except Exception, e:
>+                if len(headers) > 1:
>+                    self.fail(str(e))
>+            self.assertEqual(centre, headers[1])
>+        
>+            #Check the right hand column
>+            right = ''
>+            try:
>+                right = csp.left_column_heading
>+            except Exception, e:
>+                if len(headers) > 2:
>+                    self.fail(str(e))
>+            self.assertEqual(right, headers[2])
>+
>+    def test_that_option_group_matches_visible_columns_for_Thunderbird(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        self.assertTrue('Thunderbird' in csp.page_title)
>+        details = csp.current_details
>+        headers = []
>+        for i in details['versions']:
>+            headers.append(details['product'] + ' ' + i)
>+
>+        if len(headers) > 0:
>+            self.assertEqual(headers[0], csp.right_column_heading)
>+    
>+            #Check the centre column
>+            centre = ''
>+            try:
>+                centre = csp.centre_column_heading
>+                self.assertEqual(centre, headers[1])
>+            except Exception, e:
>+                if len(headers) > 1:
>+                    self.fail(str(e))
>+
>+            #Check the right hand column
>+            right = ''
>+            try:
>+                right = csp.left_column_heading
>+                self.assertEqual(centre, headers[2])
>+            except Exception, e:
>+                if len(headers) > 2:
>+                    self.fail(str(e))
>+
>+    def test_that_option_group_matches_visible_columns_for_Camino(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        self.assertTrue('Camino' in csp.page_title)
>+        details = csp.current_details
>+        headers = []
>+        for i in details['versions']:
>+            headers.append(details['product'] + ' ' + i)
>+        
>+        if len(headers) > 0:
>+            self.assertEqual(headers[0], csp.right_column_heading)
>+        
>+            #Check the centre column
>+            centre = ''
>+            try:
>+                centre = csp.centre_column_heading
>+                self.assertEqual(centre, headers[1])
>+            except Exception, e:
>+                if len(headers) > 1:
>+                    self.fail(str(e))
>+                
>+            #Check the right hand column
>+            right = ''
>+            try:
>+                right = csp.left_column_heading
>+                self.assertEqual(centre, headers[2])
>+            except Exception, e:
>+                if len(headers) > 2:
>+                    self.fail(str(e))
>+
>+    def test_that_option_group_matches_visible_columns_for_SeaMonkey(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        self.assertTrue('SeaMonkey' in csp.page_title)
>+        details = csp.current_details
>+        headers = []
>+        for i in details['versions']:
>+            headers.append(details['product'] + ' ' + i)
>+
>+        if len(headers) > 0:
>+            self.assertEqual(headers[0], csp.right_column_heading)
>+    
>+            #Check the centre column
>+            centre = ''
>+            try:
>+                centre = csp.centre_column_heading
>+                self.assertEqual(centre, headers[1])
>+            except Exception, e:
>+                if len(headers) > 1:
>+                    self.fail(str(e))
>+                
>+            #Check the right hand column
>+            right = ''
>+            try:
>+                right = csp.left_column_heading
>+                self.assertEqual(centre, headers[2])
>+            except Exception, e:
>+                if len(headers) > 2:
>+                    self.fail(str(e))
>+
>+    def test_that_option_group_matches_visible_columns_for_Fennec(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        self.assertTrue('Fennec' in csp.page_title)
>+        details = csp.current_details
>+        headers = []
>+        for i in details['versions']:
>+            headers.append(details['product'] + ' ' + i)
>+
>+        if len(headers) > 0:
>+            self.assertEqual(headers[0], csp.right_column_heading)
>+        
>+            #Check the centre column
>+            centre = ''
>+            try:
>+                centre = csp.centre_column_heading
>+                self.assertEqual(centre, headers[1])
>+            except Exception, e:
>+                if len(headers) > 1:
>+                    self.fail(str(e))
>+                
>+            #Check the right hand column
>+            right = ''
>+            try:
>+                right = csp.left_column_heading
>+                self.assertEqual(centre, headers[2])
>+            except Exception, e:
>+                if len(headers) > 2:
>+                    self.fail(str(e))
>+
>+    def test_that_clicking_on_top_changers_updates(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        try:
>+            csp.click_on_top_('Changers')
>+        except Exception,e:
>+            self.fail(str(e))
>+        class_attr = csp.get_attribute('link=Top Changers','class')
>+        self.assertEqual("selected", class_attr)
>+
>+    def test_that_server_status_page_loads(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csstat = csp.click_server_status()
>+        try:
>+            csstat.at_a_glance()
>+        except Exception, e:
>+            self.fail(str(e))
>+
>+        try:
>+            csstat.graphs()
>+        except Exception, e:
>+            self.fail(str(e))
>+
>+        try:
>+            csstat.latest_raw_stats()
>+        except Exception, e:
>+            self.fail(str(e))
>+
>+    def test_that_options_are_sorted_the_same(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        cssearch = csp.click_advanced_search()
>+        nav_product_list = csp.get_product_list
>+        search_product_list = cssearch.product_list
>+        self.assertEqual(len(nav_product_list),len(search_product_list))
>+        for i, prod_item in enumerate(nav_product_list):
>+            self.assertEqual(prod_item, search_product_list[i])
>+
>+    def test_that_advanced_search_has_firefox_highlighted_in_multiselect(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        cs_advanced = csp.click_advanced_search()
>+        self.assertEqual('Firefox', cs_advanced.currently_selected_product)
>+
>+    def test_that_advanced_search_has_thunderbird_highlighted_in_multiselect(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        cs_advanced = csp.click_advanced_search()
>+        self.assertEqual('Thunderbird', cs_advanced.currently_selected_product)
>+    
>+    def test_that_advanced_search_has_fennec_highlighted_in_multiselect(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        cs_advanced = csp.click_advanced_search()
>+        self.assertEqual('Fennec', cs_advanced.currently_selected_product)
>+    
>+    def test_that_advanced_search_has_camino_highlighted_in_multiselect(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        cs_advanced = csp.click_advanced_search()
>+        self.assertEqual('Camino', cs_advanced.currently_selected_product)
>+
>+    def test_that_advanced_search_has_seamonkey_highlighted_in_multiselect(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        cs_advanced = csp.click_advanced_search()
>+        self.assertEqual('SeaMonkey', cs_advanced.currently_selected_product)
>+
>+    def test_that_advanced_search_view_signature_for_firefox_crash(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        if not cs_advanced.can_find_text('no data'):
>+            signature = cs_advanced.click_first_signature()
>+            self.assertTrue(signature in cs_advanced.page_heading)
>+
>+    def test_that_advanced_search_view_signature_for_thunderbird_crash(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        if not cs_advanced.can_find_text('no data'):
>+            signature = cs_advanced.click_first_signature()
>+            self.assertTrue(signature in cs_advanced.page_heading)
>+
>+    def test_that_advanced_search_view_signature_for_fennec_crash(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        if not cs_advanced.can_find_text('no data'):
>+            signature = cs_advanced.click_first_signature()
>+            self.assertTrue(signature in cs_advanced.page_heading)
>+
>+    def test_that_advanced_search_view_signature_for_camino_crash(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        if not cs_advanced.can_find_text('no data'):
>+            signature = cs_advanced.click_first_signature()
>+            self.assertTrue(signature in cs_advanced.page_heading)
>+
>+    def test_that_advanced_search_view_signature_for_seamonkey_crash(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        if not cs_advanced.can_find_text('no data'):
>+            signature = cs_advanced.click_first_signature()
>+            self.assertTrue(signature in cs_advanced.page_heading)
>+
>+    def test_that_simple_querystring_doesnt_return_500(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.get_url_path('/query/simple')
>+        self.assertNotEqual('Framework Error', csp.page_title)
>+
>+
>+
>+if __name__ == "__main__":
>+    unittest.main()
>Index: test_search.py
>===================================================================
>--- test_search.py	(revision 0)
>+++ test_search.py	(revision 0)
>@@ -0,0 +1,68 @@
>+#!/usr/bin/env python
>+import unittest
>+from selenium import selenium
>+from crash_stats_page import CrashStatsHomePage
>+from crash_stats_page import CrashStatsSearchResults
>+from vars import ConnectionParameters
>+
>+
>+class TestSearchForIdOrSignature(unittest.TestCase):
>+
>+    def setUp(self):
>+        self.selenium = selenium(ConnectionParameters.server, ConnectionParameters.port,
>+                    ConnectionParameters.browser, ConnectionParameters.baseurl)
>+        self.selenium.start()
>+
>+    def tearDown(self):
>+        self.selenium.stop()
>+
>+    def test_that_when_item_not_available(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        results = csp.search_for_crash("this won't exist")
>+        self.assertTrue(results.can_find_text('No results were found.'))
>+
>+    def test_that_search_for_valid_signature(self):
>+        '''
>+            This is a test for 
>+                https://bugzilla.mozilla.org/show_bug.cgi?id=609070
>+        '''
>+        csp = CrashStatsHomePage(self.selenium)
>+        result = csp.search_for_crash(csp.first_signature)
>+        self.assertFalse(result.can_find_text('No results were found.'))
>+
>+    def test_that_advanced_search_for_firefox_can_be_filtered(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        self.assertTrue(cs_advanced.can_find_text('product is one of Firefox'))
>+
>+    def test_that_advanced_search_for_thunderbird_can_be_filtered(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Thunderbird')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        self.assertTrue(cs_advanced.can_find_text('product is one of Thunderbird'))
>+
>+    def test_that_advanced_search_for_fennec_can_be_filtered(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Fennec')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        self.assertTrue(cs_advanced.can_find_text('product is one of Fennec'))
>+
>+    def test_that_advanced_search_for_camino_can_be_filtered(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('Camino')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        self.assertTrue(cs_advanced.can_find_text('product is one of Camino'))
>+    
>+    def test_that_advanced_search_for_seamonkey_can_be_filtered(self):
>+        csp = CrashStatsHomePage(self.selenium)
>+        csp.select_product('SeaMonkey')
>+        cs_advanced = csp.click_advanced_search()
>+        cs_advanced.filter_reports()
>+        self.assertTrue(cs_advanced.can_find_text('product is one of SeaMonkey'))  
>+
>+if __name__ == "__main__":
>+    unittest.main()

Rest looks good to me, a non-Python, non-coding guy :-)
Attachment #491531 - Flags: feedback?(stephen.donner) → feedback+
Comment on attachment 491531 [details] [diff] [review]
Socorro Selenium Tests

In vars.py we don't need :
1. class configOptions
2. variable authurl
Attachment #491531 - Flags: review?(vish.mozilla) → review+
I just noticed that you have all the page classes in one file. Are you going to leave them in one file or are you going to have separate files for each page class?
Comment on attachment 491531 [details] [diff] [review]
Socorro Selenium Tests

This is awesome.

Further to discussion in IRC, I'd like a way to generage coverage maps.
Attachment #491531 - Flags: feedback?(laura) → feedback+
Comment on attachment 491531 [details] [diff] [review]
Socorro Selenium Tests

Looks good to me, very readable.
Attachment #491531 - Flags: feedback?(robert) → feedback+
pushed to SVN r78009
passing tests http://qa-selenium.mv.mozilla.com:8080/job/Socorro/11/
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
These Socorro tests on hudson will run every morning at 1 am PST.
Suggestion: we should add "selenium.set_timeout(vars.ConncetionParameters.page_load_timeout) to setUp() of every test case. This will make the open() command wait longer and we will have fewer timeout issues.
Attachment #491531 - Flags: review?(tgavankar)
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: