当前位置: 首页>>代码示例>>Python>>正文


Python Select.deselect_by_visible_text方法代码示例

本文整理汇总了Python中selenium.webdriver.support.select.Select.deselect_by_visible_text方法的典型用法代码示例。如果您正苦于以下问题:Python Select.deselect_by_visible_text方法的具体用法?Python Select.deselect_by_visible_text怎么用?Python Select.deselect_by_visible_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.support.select.Select的用法示例。


在下文中一共展示了Select.deselect_by_visible_text方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove_selection

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_by_visible_text [as 别名]
 def remove_selection(self, locator, optionLocator):
     el = self.driver.find_element(self.getBy(selectLocator), self.getValue(selectLocator))
     select = Select(el)
     logging.debug(select.options)
     if "label=" in optionLocator:
         select.deselect_by_visible_text(optionLocator[6:])
     elif "value=" in optionLocator:
         select.deselect_by_value(optionLocator[6:])
开发者ID:caizhenxing,项目名称:Python-WebDriver-Backed-Selenium-RC,代码行数:10,代码来源:seleniumbacked.py

示例2: deselect_option

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_by_visible_text [as 别名]
    def deselect_option(self, value=None, text=None, index=None):
        if len(list(filter(None, (value, text, index)))) != 1:
            raise ValueError("You must supply exactly one of (value, text, index) kwargs")

        select = Select(self)
        if value is not None:
            select.deselect_by_value(value)
        elif text is not None:
            select.deselect_by_visible_text(text)
        else:
            select.deselect_by_index(index)
开发者ID:wbrp,项目名称:webdriverplus,代码行数:13,代码来源:webelement.py

示例3: __delitem__

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_by_visible_text [as 别名]
 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)
开发者ID:Element-34,项目名称:py.saunter,代码行数:14,代码来源:multi_select.py

示例4: _select_combo_box

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_by_visible_text [as 别名]
 def _select_combo_box(self, combo_box_identifier, option_name=None, page_load=False, timeout=5, option_name_list=None, by=By.NAME):
     """
     DESCRIPTION:
         Find the select element defined by combo_box_identifier and by, and select the provided option(s). If page_load is True, wait
         during timeout seconds until a new page is loaded before returning. In case of a multiple selection, clear the previous 
         selection before doing any new selection.
         If the combo box is a single combo box, and option name is already selected, it will return immediately, even if page_load
         is set to True. The same happens if the combo box is a multiple combo box, and option_name_list matches exactly the current
         selected options.
     INPUT:
         combo_box_identifier: The identifier used to find the combo box. This parameter and the "by" parameter are used together
             to create a locator.
         option_name: The name of a single option to select. Exactly one among option_name and option_name_list must be provided.
             If option_name is provided and the combo box is a multiple combo box, it is strictly identical as if
             option_name_list was provided as an iterable of 1 element. The selection is done according to the displayed text of the
             option, and not according to its value. The default value is None.
         page_load: If it is True, the function will wait for a new page being loaded before returning. If the combo box is a
             multiple combo box, and option_name_list contains more than 1 element, it will wait between each selection. The default
             value is False.
         timeout: The number of seconds to wait before raising a TimeoutException if a new page does not load.
         option_name_list: An iterator containing the name of options to select. Exactly one among option_name and option_name_list
             must be provided. If option_name_list is provided, but the combo box is a single combo box, a RuntimeError is raised,
             even if option_name_list contains only 1 element. The selection is done according to the displayed text of the option,
             and not according to its value. The default value is None.
         by: Defined how the combo box will be looked for. It forms a locator with combo_box_identifier. The default value is
             By.Name.
     OUTPUT:
         Return True if at least one selection has been performed, otherwise False. In other words, return False if the selected 
         option matches with the provided option_name for a single combo box, or if the selected options match with the provided
         option_name_list for a multiple combo box.
     ERROR:
         Raise a RuntimeError if neither or both of option_name and option_name_list are not None.
         Raise a RuntimeError if option_name_list is provided, but the combo box is a single combo box.
         Raise a TimeoutException if page_load is True but the page did not refresh in timeout seconds.
         Raise a StaleElementReferenceException if the combo box is a multiple combo box, more than one selection need to be done
             and page_load is False whereas the page is refreshed between each selection.
         Raise a UnexpectedTagNameException when the locator (combo_box_identifier, by) locates an element, but this element is
             not a combo box.
         Raise a NoSuchElementException when no element can be referred by the locator (combo_box_idenfifier, by).
     """
     if (option_name is None and option_name_list is None) or (option_name is not None and option_name_list is not None):
         raise RuntimeError("Exactly 1 among option_name and option_name_list must be None")
     
     select_element = self.driver.find_element(by, combo_box_identifier)
     is_multiple = select_element.get_attribute("multiple")
     select_element = Select(select_element)
     if option_name_list is not None and not is_multiple:
         raise RuntimeError("Can't select multiple value in a single select")
     
     if option_name is not None:
         # If the value is already selected, there is nothing to be done
         if select_element.first_selected_option.text == option_name:
             return False
         option_name_list = [option_name]
     
     if is_multiple:
         if set([option.text for option in select_element.all_selected_options]) == set(option_name_list):
             return False
             
         if page_load:
             # We have to deselect element one by one, as the select element will stale with deselect_all 
             while len(select_element.all_selected_options) != 0:
                 option = select_element.first_selected_option
                 with self.wait_for_page_load(timeout):
                     select_element.deselect_by_visible_text(option.text)
                 # As the page is reloaded, we have to look again for the element
                 select_element = Select(self.driver.find_element(by, combo_box_identifier))
         else:
             select_element.deselect_all()
                 
         
     for option_name in option_name_list:
         if page_load:
             with self.wait_for_page_load(timeout):
                 select_element.select_by_visible_text(option_name)
                 # As the page is reloaded, we have to look again for the element in case of multiple selection
                 select_element = Select(self.driver.find_element(by, combo_box_identifier))
         else:
             select_element.select_by_visible_text(option_name)
     return True
开发者ID:orion-research,项目名称:coach,代码行数:82,代码来源:TestGlobal.py


注:本文中的selenium.webdriver.support.select.Select.deselect_by_visible_text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。