Exemplo n.º 1
0
    def test_get_widget_by_name_and_verify_caching_is_faster_than_initial_get(self):

         widgets = {"widget_0" : "Personal Data",
                   "widget_1" : "Family Details",
                   "widget_2" : "Communication",
                   "widget_3" : "Bank Details",
                   "widget_4" : "Address",
                   "widget_5" : "Pending Requests",
                   "fwk_menu_1" : "My Details",
                   "fwk_menu_3" : "My Selections"}

         testTime = time.clock()
        
         #first time through we should have the dev suplied ids
         for (id, name) in widgets.iteritems():
                returned_widget = LIB._get_widget_by_name(name)
                #by default id with be changed to chached name first time widget is found
                self.assertEquals("%s_widget" % (name), returned_widget.get_attribute('id'))
         firstRunTime = time.clock() - testTime
         print "get widget by name without caching time is %f" % (firstRunTime)

         cachedRunStart = time.clock()
         #after which everything should be cached
         for (id, name) in widgets.iteritems():
            returned_widget = LIB._get_widget_by_name(name)
            self.assertEquals("%s_widget" % (name), returned_widget.get_attribute('id'))
         cachedRunStop = time.clock() - cachedRunStart
         print "Time for cached run was %f" % (cachedRunStop)
         self.assertTrue(cachedRunStop < firstRunTime)
         fullTestTime = time.clock() - testTime
         print "Total time for test was %f" % (fullTestTime)
Exemplo n.º 2
0
 def test_euh_select_drop_down_field_value_logs_warning_if_value_not_displayed(self):
     self.was_called = False
     old_warn = LIB._warn
     LIB._warn = self.mock_warn
     LIB.euh_select_drop_down_field_value("Language","not a language",widget_name="Personal Data")
     LIB._warn = old_warn
     self.assertTrue(self.was_called)
Exemplo n.º 3
0
 def test_set_unique_text_value(self):
     self.navigate(data.PD_URL)
     val1 = LIB.euh_set_unique_text_value("Last name", "test",widget_name="Personal Data")
     val2 = LIB.euh_set_unique_text_value("Last name", "test", widget_name="Personal Data")
     val3 = LIB.euh_set_unique_text_value("Last name", "test",widget_name="Personal Data")
     val4 = LIB.euh_set_unique_text_value("Last name", "test", widget_name="Personal Data")
     self.assertTrue(val1 != val2 != val3 != val4)
Exemplo n.º 4
0
 def test_euh_select_drop_down_field_value(self):
     langs = [u'Afrikaans', u'Espa\xf1ol',u'Ukrainian',u'\u05e2\u05d1\u05e8\u05d9\u05ea']
     for lang in langs:
         LIB.euh_select_drop_down_field_value("Language",lang,widget_name="Personal Data")
         #make sure we click somethign else to ensure that the drop down is really set
         self.set_and_check_date_value("Date of birth", "10.10.1975","Personal Data")
         LIB.euh_check_default_drop_down_field_value("Language", lang, widget_name="Personal Data")
Exemplo n.º 5
0
    def test_euh_check_button_existence_by_index(self):
        self.navigate(data.PD_URL)
        btn = LIB.euh_check_button_existence(button_name="Save",index=0)
        self.assertEquals("Save", btn.text)
        self.assertEquals("my_fake_button", btn.get_attribute("id"))

        btn = LIB.euh_check_button_existence(button_name="Save",index=1)
        self.assertEquals("Save", btn.text)
        self.assertEquals("centerRoundedButton test_button", btn.get_attribute("class"))
Exemplo n.º 6
0
    def test_verify_widget_caching_behavior(self):
        self.navigate(data.PD_URL)
        widget_id = "fwk_menu_16"
        widget_name = "Related Links"

        #initially widget is uncached
        self.assertIsNone(LIB._is_widget_cached(widget_name))
        #call with cache_widget = False and widget is Not cached
        t0 = time.clock()
        LIB._get_widget_by_name(widget_name, False)
        uncached_retrival_time = time.clock() - t0
        self.assertIsNone(LIB._is_widget_cached(widget_name))
        #default - call with cach_widget = True and widget is cached
        widget = LIB._get_widget_by_name(widget_name)
        t1 = time.clock()
        cached_widget = LIB._get_widget_by_name(widget_name)
        cached_retrival_time = time.clock() - t1
        self.assertEqual(widget.text, cached_widget.text)
        self.assertTrue(cached_retrival_time < uncached_retrival_time)
        print "Uncached retrival time = %f Cached retrival time = %f" % (uncached_retrival_time, cached_retrival_time)
        #and widget id should be set to name_widget
        self.assertEqual("%s_widget" % (widget_name), widget.get_attribute('id'))
        #and cache should be invalidated after reload
        LIB.reload_page()
        self.assertIsNone(LIB._is_widget_cached(widget_name))
Exemplo n.º 7
0
    def test_find_euh_dropdown_returns_appropriate_type_of_dropdown(self):
        dropdown = LIB._find_euh_dropdown("Language", "Personal Data")
        self.assertEquals(DC.Dropdown, dropdown[1])
        self.assertEquals("select", dropdown[0].tag_name)
        
        auto_dropdown = LIB._find_euh_dropdown("Nationality", "Personal Data")
        self.assertEquals(DC.AutocompleteDropDown, auto_dropdown[1])
        self.assertEquals("input", auto_dropdown[0].tag_name)

        nota_dropdown = LIB._find_euh_dropdown("Last name", "Personal Data")
        self.assertIsNone(nota_dropdown[1])
        self.assertEquals("div", nota_dropdown[0].tag_name)
Exemplo n.º 8
0
 def test_euh_click_ee_bubble_option_list(self):
     self.navigate(data.EE_URL)
     LIB.euh_click_ee_bubble_option_list("Clock IN / OUT")
     LIB.euh_click_ee_bubble_option_list("Clock IN / OUT", "30000290", "My Details")
     LIB.euh_click_ee_bubble_option_list("Clock IN / OUT", "30000290_Time Error_Correct Time_Emp", "My Details")
     LIB.euh_click_ee_bubble_option_list("Clock IN / OUT", "30000290_Time Error_Correct", "my details")
     self.assertRaisesRegexp(RuntimeError, "you must specify widget_name if you specify button_name for _get_ee_button",
         LIB.euh_click_ee_bubble_option_list,"Clock IN / OUT", "30000290")
Exemplo n.º 9
0
    def test_find_button_by_name_inside_of_a_widget(self):
        self.navigate(data.PD_URL)
        expected_button_names= ["Save", "Cancel"]

        for name in expected_button_names:
            my_button = LIB._get_button_by_name(name,'Personal Data')
            self.assertEquals(name, my_button.text)
Exemplo n.º 10
0
 def verify_elements_in_widget(self, widget_name,dummy_class,expected_link_names,expected_ids):
     links = LIB._get_via_dummy_class(dummy_class, widget_name=widget_name)
     #verify link names
     link_names = [link.text for link in links]
     self.assertItemsEqual(expected_link_names, link_names)
     #verify link IDs
     link_ids = [link.get_attribute('id') for link in links]
     self.assertItemsEqual(expected_ids, link_ids)
Exemplo n.º 11
0
 def test_get_elements_via_dummy_class_with_no_widget_still_finds_elements_inside_widget(self):
     self.navigate(data.PD_URL)
     labels = LIB._get_via_dummy_class(DC.Label)
     #list of labels that don't implmenet the for_ ID pattern to identify the associated control
     #print "\n".join([lbl.text for lbl in labels if not lbl.get_attribute("id").startswith("for_")])
     self.assertEquals(39, len(labels))
     #ensure we find stuff like Title, Last name, first name that are in the Personal Data widget
     from sets import Set
     expected_Label_Names=Set(["Title","Last name","First name"])
     actual_Label_Names =Set([lbl.text for lbl in labels])
     self.assertTrue(expected_Label_Names.issubset(actual_Label_Names))
Exemplo n.º 12
0
    def test_find_euh_top_menu_buttons(self):
        data = ("employee data", "time management", "Payroll Data", "BENEFITS", "WorKFORce administration", "TaLeNt MaNaGeMeNt",
            "Strategy & Communication","Service Center")

        for topmenu_name in data:
            button = LIB._get_euh_top_menu_button(topmenu_name)
            self.assertEquals("button", button.tag_name)
            locator = OR["topmenu_%s" % (topmenu_name.lower())][5:]
            button_id = locator.split(" > ")[0]
            #print "name = %s button_id = %s button class = %s" % (topmenu_name, button_id, button.get_attribute("class"))
            self.assertTrue(button.get_attribute("class").find(button_id) > -1)
Exemplo n.º 13
0
    def test_get_widget_by_name(self):
        widgets = {"widget_0" : "Personal Data",
                   "widget_1" : "Family Details",
                   "widget_2" : "Communication",
                   "widget_3" : "Bank Details",
                   "widget_4" : "Address",
                   "widget_5" : "Pending Requests",
                   "fwk_menu_1" : "My Details",
                   "fwk_menu_3" : "My Selections"}

        #if no caching we should have the dev suplied ids
        for (id, name) in widgets.iteritems():
                returned_widget = LIB._get_widget_by_name(name,False)
                self.assertEquals(id, returned_widget.get_attribute('id'))
Exemplo n.º 14
0
 def test_get_element_by_label(self):
     self.navigate(data.PD_URL)
     expected_data = {"PD_DATA_1_1_ANRED": "Title",
                     "PD_DATA_1_1_NACHN": "Last name",
                     "PD_DATA_1_1_VORNA": "First name",
                     "PD_DATA_1_1_GBDAT": "Date of birth",
                     "PD_DATA_1_1_NATIO": "Nationality",
                     "PD_DATA_1_1_SPRSL":"Language",
                     "PD_DATA_1_1_BEGDA": "Start Date",
                     "PD_DATA_1_1_ENDDA": "End Date"}
     
     for (id,name) in expected_data.iteritems():
         element = LIB._get_element_by_label(name,widget_name="Personal Data")
         self.assertEquals(id,element.get_attribute("id"))
Exemplo n.º 15
0
    def test_check_time_uses_belgium_time_zone(self):
        self.navigate(data.TIME_URL)
        from datetime import datetime, timedelta
        time_value = datetime.now().strftime("%I:%M:%S")
        LIB.euh_set_time_value("From",time_value)
        self.assertRaises(ValidationFailedError,LIB.euh_check_time_value,"From", "<<current min>>")

        belgium_time_value = (datetime.utcnow() + timedelta(hours=1)).strftime("%I:%M:%S")
        LIB.euh_set_time_value("From",belgium_time_value)
        LIB.euh_check_time_value("From", "<<current min>>")
Exemplo n.º 16
0
 def test_get_widget_with_limited_widgets_on_the_page_should_be_fast(self):
     self.navigate(data.LIMITED_WIDGETS_URL)
     
     wait = LIB.get_selenium_implicit_wait()
     try:
         LIB.set_browser_implicit_wait(2)
         t0 = time.clock()
         returned_widget = LIB._get_widget_by_name("Personal Data", False)
         t1 = time.clock()
         self.assertTrue((t1-t0) <2) #we get it faster than the implic_wait time, meaning we aren't using the wait time 
         self.assertEquals("widget_0",returned_widget.get_attribute("id"))
         
     finally:
         LIB.set_browser_implicit_wait(wait)
Exemplo n.º 17
0
 def test_set_and_check_time_value(self):
     self.navigate(data.TIME_URL)
     LIB.euh_set_time_value("From","10:00")
     LIB.euh_check_time_value("From","10:00")
Exemplo n.º 18
0
 def set_and_check_date_value(self,textbox_name,val,widget=None):
     LIB.euh_set_date_value(textbox_name, val,widget)
     LIB.euh_check_default_date_value(textbox_name,val,widget)
Exemplo n.º 19
0
 def set_and_check_text_value(self,textbox_name,val,widget):
     LIB.euh_set_text_value(textbox_name, val,widget)
     LIB.euh_check_default_textbox_value(textbox_name,val,widget)
Exemplo n.º 20
0
 def tearDownClass(cls):
     pass
     LIB.close_browser()
Exemplo n.º 21
0
 def test_find_button_by_name_no_widget(self):
     self.navigate(data.LOGIN_URL)
     self.assertEquals("Login", LIB._get_button_by_name("Login").text)
Exemplo n.º 22
0
 def setUpClass(cls):
     ewslibTestCase.setUpClass()
     LIB.open_browser(data.PD_URL, data.BROWSER)     
Exemplo n.º 23
0
 def test_euh_click_tree_items_honors_index(self):
     self.navigate(data.TREE_URL)
     LIB.euh_click_tree_item("GAMO_GL_SC_OM_MM_Organization Unit 03", index=0)
     LIB.euh_click_tree_item("GAMO_GL_SC_OM_MM_Organization Unit 03", index=1)
     LIB.euh_click_tree_item("GAMO_GL_SC_OM_MM_Organization Unit 03", index=2)
     self.assertRaises(IndexError, LIB.euh_click_tree_item,"GAMO_GL_SC_OM_MM_Organization Unit 03", index=3)
Exemplo n.º 24
0
 def test_euh_select_dropdown_field_value_using_OR(self):
     self.navigate(data.POPUP_URL)
     LIB.euh_select_drop_down_field_value("OR:ClockIn_Reason", "test")
Exemplo n.º 25
0
 def test_euh_autocomplete_drop_down_field_value(self):
     self.navigate(data.PD_URL)
     LIB.euh_select_drop_down_field_value("Nationality", "american", widget_name="Personal Data")
Exemplo n.º 26
0
 def test_euh_click_tree_items_can_use_OR(self):
     self.navigate(data.TREE_URL)
     OR["test_tree_item"] = "id=OM_BAM_level5_linedTreeTxt_O50003462"
     LIB.euh_click_tree_item("OR:test_tree_item")
Exemplo n.º 27
0
 def test_click_button(self):
     LIB.euh_click_button(button_name="Save", index=1)
     LIB.euh_click_button(button_name="Save", widget_name="Personal Data")
     LIB.euh_click_button(button_name="Cancel",widget_name="Personal Data")
Exemplo n.º 28
0
 def test_set_uniqe_text_value_limit_size(self):
     self.navigate(data.PD_URL)
     val1 = LIB.euh_set_unique_text_value("Last name", "test",widget_name="Personal Data")
     self.assertTrue(20,len(val1))
     val2 = LIB.euh_set_unique_text_value("Last name", "test",length="10",widget_name="Personal Data")
     self.assertTrue(10,len(val2))
Exemplo n.º 29
0
 def test_set_text_area(self):
     self.navigate(data.TEXT_AREA_URL)
     LIB.euh_set_text_area_value("OR:om_maintain_general_description", "test")
     LIB.euh_check_text_area_value("OR:om_maintain_general_description", "test")
Exemplo n.º 30
0
 def test_find_button_by_name_no_widget_finds_button_outside_of_widget(self):
     self.navigate(data.PD_URL)
     btn = LIB._get_button_by_name(button_name="Save")
     self.assertEquals("Save", btn.text)
     self.assertEquals("my_fake_button", btn.get_attribute("id"))