Beispiel #1
0
 def __getitem__(self, key):
     s = WebDriverSelect(self.driver.find_element_by_locator(self.locator))
     a = s.all_selected_options
     if len(a) == 0:
         return None
     selections = [x.text for x in a]
     return selections[key]
Beispiel #2
0
    def change_email_priority(self):
        element = EditUsersPageElements(self.driver)
        email = "bla" + UsersPageElements(self.driver).sonik_pass_domen()
        add_button = element.add_email_button()
        username = element.username_input()
        label = WebDriverSelect(element.email_label())
        value = 1

        add_button.click()
        email_input = element.second_email_input()

        email_input.click()
        email_input.send_keys(email)
        username.click()

        for x in range(5):
            label.select_by_value(str(value))
            selected_option = label.first_selected_option.text
            if value == 0:
                assert selected_option == 'Primary', "Selected option should be Primary"

            elif value == 1:
                assert selected_option == 'Secondary', "Selected option should be Secondary"

            elif value == 2:
                assert selected_option == 'Work', "Selected option should be Work"

            elif value == 3:
                assert selected_option == 'Personal', "Selected option should be Personal"

            elif value == 4:
                assert selected_option == 'Other', "Selected option should be Other"

            value += 1
 def test_example_2(self):
     driver = self.driver
     driver.get('http://the-internet.herokuapp.com/dropdown')
     dropdown = driver.find_element_by_id('dropdown')
     select_list = WebDriverSelect(dropdown)
     select_list.select_by_visible_text('Option 1')
     selected_option = select_list.first_selected_option.text
     assert selected_option == 'Option 1', "Selected option should be Option 1"
 def setShowEntries(self, value):
     try:
         ddElement = WebDriverWait(self.driver, 20).until(
             EC.presence_of_element_located(
                 (By.XPATH, "//div[@id='serverSideDataTable_length']//select[@name='serverSideDataTable_length']")))
         select_list = WebDriverSelect(ddElement)
         selected_option = select_list.select_by_value('100')
         return select_list, selected_option
     except (Exception) as e:
         print("Error occurred:", e)
Beispiel #5
0
    def default_name_order(self):

        try:
            position = WebDriverSelect(self._find(self._goods_display_order))
            display_name = position.first_selected_option

        except Error:
            raise

        else:
            return display_name
Beispiel #6
0
    def test_example_drop_down(self):
        driver = self.driver
        driver.get("http://the-internet.herokuapp.com/dropdown")
        option = driver.find_element_by_id("dropdown")

        select_list = WebDriverSelect(option)
        select_list.select_by_visible_text('Option 2')
        selection_option = select_list.first_selected_option.text
        #all_selected_options
        #deselect_all()
        #deselect_by_visible_text
        assert selection_option == "Option 2"
Beispiel #7
0
 def selected(self, val):
     s = WebDriverSelect(self.driver.find_element_by_locator(self.locator))
     method = val[:val.find("=")]
     value = val[val.find("=") + 1:]
     if method == "value":
         s.select_by_value(value)
     elif method == "index":
         s.select_by_index(value)
     elif method == "text":
         s.select_by_visible_text(value)
     else:
         raise saunter.exceptions.InvalidLocatorString(val)
Beispiel #8
0
 def __get__(self, obj, cls=None):
     try:
         s = WebDriverSelect(
             obj.driver.find_element_by_locator(self.locator))
         e = s.first_selected_option
         return str(e.text)
     except AttributeError as e:
         if str(
                 e
         ) == "'SeleniumWrapper' object has no attribute 'connection'":
             pass
         else:
             raise e
Beispiel #9
0
 def append(self, item):
     s = WebDriverSelect(self.driver.find_element_by_locator(self.locator))
     method = item[:item.find("=")]
     value = item[item.find("=") + 1:]
     if method == "value":
         s.select_by_value(value)
     elif method == "index":
         s.select_by_index(value)
     elif method == "text":
         s.select_by_visible_text(value)
     else:
         raise saunter.exceptions.InvalidLocatorString(
             "%s is an invalid locator" % item)
Beispiel #10
0
 def __delitem__(self, key):
     s = WebDriverSelect(self.driver.find_element_by_locator(self.locator))
     method = key[:key.find("=")]
     value = key[key.find("=") + 1:]
     if method == "value":
         s.deselect_by_value(value)
     elif method == "index":
         s.deselect_by_index(value)
     elif method == "text":
         s.deselect_by_visible_text(value)
     else:
         raise saunter.exceptions.InvalidLocatorString(
             "%s is an invalid locator" % item)
Beispiel #11
0
 def selected(self):
     s = WebDriverSelect(self.driver.find_element_by_locator(self.locator))
     e = s.first_selected_option
     return str(e.text)
 def _select_dropdown(self, locator, option_number):
     select_list = WebDriverSelect(locator)
     select_list.select_by_visible_text(option_number)
     selected_option = select_list.first_selected_option.text
     return selected_option == (option_number), ("Selected option should be " + (option_number))
Beispiel #13
0
 def change_role(self):
     dropdown = EditUsersPageElements(self.driver).role_select()
     select_list = WebDriverSelect(dropdown)
     select_list.select_by_value('0')
     selected_option = select_list.first_selected_option.text
     assert selected_option == 'admin', "Selected option should be Admin"
Beispiel #14
0
 def __len__(self):
     s = WebDriverSelect(self.driver.find_element_by_locator(self.locator))
     return len(s.all_selected_options)
Beispiel #15
0
 def __get__(self, obj, cls=None):
     s = WebDriverSelect(obj.driver.find_element_by_locator(self.locator))
     a = s.all_selected_options
     if len(a) == 0:
         return None
     return [x.text for x in a]
Beispiel #16
0
 def options(self):
     s = WebDriverSelect(self.driver.find_element_by_locator(self.locator))
     options = s.options
     text = [option.text.strip() for option in options]
     return text
Beispiel #17
0
    def name_display_order(self):
        position = WebDriverSelect(self._find(self._goods_display_order))
        display_name = position.first_selected_option.text

        return display_name