- Selenium WebDriver - Discussion
- Selenium WebDriver - Useful Resources
- Selenium WebDriver - Quick Guide
- Double Click
- Right Click
- Capture Screenshots
- Scroll Operations
- Chrome WebDriver Options
- JavaScript Executor
- Select Support
- Wait Support
- Headless Execution
- Executing Tests in Multiple Browsers
- Handling Checkboxes
- Read/Write data from Excel
- Generating HTML Test Reports in Python
- Color Support
- Handling Edit Boxes
- Handling Links
- Alerts
- Windows
- Drag and Drop
- Forms
- Create a Basic Test
- Action Class
- Exceptions
- Cookies
- Backward and Forward Navigation
- Pop-ups
- Explicit and Implicit Wait
- Identify Multiple Elements
- Identify Single Element
- Browser Navigation
- Installation
- Introduction
- Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Selenium Webdriver - Select Support
谷物可以在选修班的帮助下处理静态下降。 降幅由选定的标签确定,其选择用标签办法表示。 该声明――从 se.webdriver.support.select import观改为选择性班级。
Methods
选择类别下的方法如下:
select_by_visible_text (arg)
它应选择显示案文与论点相符的所有选择。
选择显示案文对应的选项的概要如下:
sel = Select (driver.find_element_by_id ("name")) sel.select_by_visible_text ( Visible Text )
select_by_ Value (arg)
委员会应选择所有具有与论点相符的价值的备选办法。 选择所有具有相同价值选项的概要如下:
sel = Select (driver.find_element_by_id ("name")) sel.select_by_value ( Value )
select_by_index (arg)
它应选择与论点相符的选择。 指数从零开始。
The syntax for selecteding the Options with same Value as per the debate is as follows -
sel = Select (driver.find_element_by_id ("name")) sel.select_by_index (1)
deselect_by_visible_text (arg)
它应忽略显示案文与论点相符的所有选择。
The syntax for diselecting all options withcomp Value as per case is as follows -
sel = Select (driver.find_element_by_id ("name")) sel.deselect_by_visible_text ( Visible Text )
deselect_by_ Value (arg)
它应当忽略所有具有与论点相符的价值的选择。
The syntax for diselecting all options withcomp Value as per case is as follows -
sel = Select (driver.find_element_by_id ("name")) sel.deselect_by_value ( Value )
deselect_by_index(arg)
它应当放弃与论点相符的选择。 指数从零开始。
The syntax for diselecting an Options withcomp Value as per the debate is as follows -
sel = Select(driver.find_element_by_id ("name")) sel.deselect_by_index(1)
它应产生所有选择,以便减少。
它应为多功能辍学或目前选定的选择方案正常下降产生第一个选择。
它应产生选定标的下的所有备选方案。
deselect_all
它将在多功能下降中清除所有选定的选择。
Code Implementation
处理有选择性的班级的静态降级的法规如下:
from selenium import webdriver from selenium.webdriver.support.select import Select driver = webdriver.Chrome(executable_path= ../drivers/chromedriver ) #imppcit wait time driver.imppcitly_wait(5) #url launch driver.get("https://the-internet.herokuapp.com/dropdown") #object of Select s= Select(driver.find_element_by_id("dropdown")) #select option by value s.select_by_value("1")
Output
产出显示,“Option 1” 选择在下降时选定。
Advertisements