zoukankan      html  css  js  c++  java
  • Python-selenium 下拉框定位

    1.通过select 进行定位下拉框

    首先selenium 很人性化的给提供了一个Select的模块,供处理下来菜单,首先我们需要导入Select,通过from selenium.webdriver.support.select import Select来导入。

    Select中提供几个用于定位的option的方法,下面看一下具体的方法

    主要把Select方法总结了一下分为三大类:

    1.选择列表

    • select_by_index(self, index)      #以index属性值来查找匹配的元素并选择;
    • select_by_value(self, value)           #以value属性值来查找该option并选择;
    • select_by_visible_text(self, text)     #以text文本值来查找匹配的元素并选择;
    • first_selected_option(self)               #选择第一个option 选项 
    # 针对按索引进行切换option属性
    Select(driver.find_element_by_id('id')).select_by_index(0)
    #针对按value进行切换option属性
    Select(driver.find_element_by_id('id)).select_by_value('abc')
    #针对按text文本进行切换option属性
    Select(driver.find_element_by_id('id')).select_by_visible_text ('text')
    

      

  • 相关阅读:
    739. Daily Temperatures
    556. Next Greater Element III
    1078. Occurrences After Bigram
    1053. Previous Permutation With One Swap
    565. Array Nesting
    1052. Grumpy Bookstore Owner
    1051. Height Checker
    数据库入门及SQL基本语法
    ISCSI的概念
    配置一个IP SAN 存储服务器
  • 原文地址:https://www.cnblogs.com/royfans/p/9934145.html
Copyright © 2011-2022 走看看