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


Python Select.deselect_by_index方法代码示例

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


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

示例1: callback

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import deselect_by_index [as 别名]
 def callback(elements):
     s = Select(elements.item)
     if i is not None:
         s.deselect_by_index(i)
     elif value is not None:
         s.deselect_by_value(value)
     elif text is not None:
         s.deselect_by_visible_text(text)
     else:
         s.deselect_all()
开发者ID:green-girl,项目名称:elementium,代码行数:12,代码来源:se.py

示例2: testDeselectByIndexMultiple

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import deselect_by_index [as 别名]
def testDeselectByIndexMultiple(driver, pages):
    pages.load("formPage.html")
    for select in [multiSelectValues1, multiSelectValues2]:
        sel = Select(driver.find_element(By.NAME, select['name']))
        sel.deselect_all()
        sel.select_by_index(0)
        sel.select_by_index(1)
        sel.select_by_index(2)
        sel.select_by_index(3)
        sel.deselect_by_index(1)
        sel.deselect_by_index(3)
        selected = sel.all_selected_options
        assert len(selected) == 2
        assert selected[0].text == select['values'][0]
        assert selected[1].text == select['values'][2]
开发者ID:Allariya,项目名称:selenium,代码行数:17,代码来源:select_class_tests.py

示例3: testDeselectByIndexMultiple

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import deselect_by_index [as 别名]
 def testDeselectByIndexMultiple(self):
     if self.driver.capabilities['browserName'] == 'chrome' and int(self.driver.capabilities['version'].split('.')[0]) < 16:
         pytest.skip("deselecting preselected values only works on chrome >= 16")
     self._loadPage("formPage")
     for select in [multiSelectValues1, multiSelectValues2]:
         sel = Select(self.driver.find_element(By.NAME, select['name']))
         sel.deselect_all()
         sel.select_by_index(0)
         sel.select_by_index(1)
         sel.select_by_index(2)
         sel.select_by_index(3)
         sel.deselect_by_index(1)
         sel.deselect_by_index(3)
         selected = sel.all_selected_options
         self.assertEqual(len(selected), 2)
         self.assertEqual(selected[0].text, select['values'][0])
         self.assertEqual(selected[1].text, select['values'][2])
开发者ID:AsafShochet,项目名称:selenium,代码行数:19,代码来源:select_class_tests.py

示例4: testDeselectByIndexMultiple

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import deselect_by_index [as 别名]
 def testDeselectByIndexMultiple(self, driver, pages):
     if driver.capabilities['browserName'] == 'chrome' and int(driver.capabilities['version'].split('.')[0]) < 16:
         pytest.skip("deselecting preselected values only works on chrome >= 16")
     pages.load("formPage.html")
     for select in [multiSelectValues1, multiSelectValues2]:
         sel = Select(driver.find_element(By.NAME, select['name']))
         sel.deselect_all()
         sel.select_by_index(0)
         sel.select_by_index(1)
         sel.select_by_index(2)
         sel.select_by_index(3)
         sel.deselect_by_index(1)
         sel.deselect_by_index(3)
         selected = sel.all_selected_options
         assert len(selected) == 2
         assert selected[0].text == select['values'][0]
         assert selected[1].text == select['values'][2]
开发者ID:zhjwpku,项目名称:selenium,代码行数:19,代码来源:select_class_tests.py

示例5: test_multiple_selection_in_list

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import deselect_by_index [as 别名]
	def test_multiple_selection_in_list(self):
		driver = self.driver
		
	 	#Get the Dropdown as a Select using it's name attribute
 		color = Select(driver.find_element_by_name("color"))
		
		#Verify Dropdown has four options for selection
		self.assertEqual(5,len(color.options))
		
		#Select multiple options in the list using visible text
		color.select_by_visible_text("Black")
		color.select_by_visible_text("Red")
		color.select_by_visible_text("Silver")
		
		#Deselect an option using visible text
		color.deselect_by_visible_text("Silver")
    	
		#Deselect an option using value attribute of the option
		color.deselect_by_value("rd")
		
		#Deselect an option using index of the option
		color.deselect_by_index(0)
开发者ID:vikramuk,项目名称:Selenium,代码行数:24,代码来源:select_test.py

示例6: select_option

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import deselect_by_index [as 别名]
    def select_option(self, obj):
        # Set local parameters
        step = obj.get('order')
        identifier_dict = obj.get('identifier')
        if identifier_dict is None:
            raise Exception('No identifier')
        child_window = obj.get('child_window')
        if child_window is None:
            raise Exception('No child_window')
        selection_value = obj.get('selection_value')
        if selection_value is None:
            raise Exception('No selection_value')
        selection_type = obj.get('selection_type')
        if selection_type is None:
            raise Exception('No selection_type')
        multiline = obj.get('multiline')
        action = None

        element = self.ei.uniquely_identify_element(identifier_dict)

        # Report no element found
        if element is None:
            action = 'No element found'
            return action

        if element is not None:

            # Prepare element for action
            self.__wait_for_post_back_to_complete(element, obj.get('timeout'))
            self.driver.execute_script('return arguments[0].scrollIntoView();', element)
            self.driver.execute_script(' window.scrollBy(0, -100);')
            selection = Select(element)
            options = selection.options
            acted_upon_options = self.__determine_acted_upon_option(options, selection_value, selection_type)

            # Determine how we are interacting with the select
            if selection_type.lower() == "index":
                action = "Select '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.select_by_index(selection_value)
            elif selection_type.lower() == "text":
                action = "Select '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.select_by_visible_text(selection_value)
            elif selection_type.lower() == "value":
                action = "Select '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.select_by_value(selection_value)
            elif selection_type.lower() == "deindex":
                action = "Deselect '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_by_index(selection_value)
            elif selection_type.lower() == "detext":
                action = "Deselect '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_by_visible_text(selection_value)
            elif selection_type.lower() == "devalue":
                action = "Deselect '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_by_value(selection_value)
            elif selection_type.lower == "deall":
                action = "Deselected all values from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_all()
            else:
                # This should really just be reported and not raise an exception
                raise Exception("Unknown selection type.")

        # Determine if action changes browser count
        if child_window:
            self.change_window_connection()

        print(action)
        return action
开发者ID:weyenk,项目名称:Zoebear,代码行数:76,代码来源:element_interaction.py


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