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


Python Select.deselect_all方法代码示例

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


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

示例1: test_13_selenium_select_default_organization_option

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_all [as 别名]
 def test_13_selenium_select_default_organization_option(self):
     from selenium.webdriver.support.select import Select
     select_organization = Select(self.filters.new_filter_menu.organizations_field.element)
     select_organization.deselect_all()
     select_organization.select_by_visible_text("ACME_Corporation")
     selected_option_value = select_organization.first_selected_option.get_attribute('value')
     self.assertElementValue(self.filters.new_filter_menu.organizations_field.element, selected_option_value)
开发者ID:RedHatQE,项目名称:splice-testing-pageobjects,代码行数:9,代码来源:test_2_filter.py

示例2: set_multiselect_field_with_id_containing

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_all [as 别名]
def set_multiselect_field_with_id_containing(field_id, filter_string):
    select_input = Select(world.browser.find_element_by_id(field_id))
    select_input.deselect_all()
    _select_option_containing(filter_string, select_input)
开发者ID:jaunis,项目名称:xivo-acceptance,代码行数:6,代码来源:select.py

示例3: deselect_version

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_all [as 别名]
 def deselect_version(self):
     element = self.selenium.find_element(*self._multiple_version_select_locator)
     select = Select(element)
     select.deselect_all()
开发者ID:AndreiH,项目名称:Socorro-Tests,代码行数:6,代码来源:advanced_search_page.py

示例4: _select_combo_box

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_all [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

示例5: remove_all_selections

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import deselect_all [as 别名]
 def remove_all_selections(self,locator):
     locator = self.deal_locator(locator)
     el = self.driver.find_element(self.getBy(selectLocator), self.getValue(selectLocator))
     select = Select(el)
     select.deselect_all()
开发者ID:limasqbank,项目名称:AHKIOO,代码行数:7,代码来源:seleniumbacked.py


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