您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页下拉框处理的两种方式

下拉框处理的两种方式

来源:二三娱乐

一种通过value的值:

def a(self,driver,element,value):

     xpath = '//option[@value="'+value+'"]'

    select = driver.find_element_by_xpath(element) #查找到select控件,这里通过xpath查找

    select.find_element_by_xpath(xpath).click()

一种通过下拉框文本:

def b(self,driver,element,value):

    select = driver.find_element_by_id(element) #查找到select控件,这里通过id查找

    options = select.find_elements_by_tag_name("option")

    for option in options:

        if option.get_attribute("textContent").encode("utf-8") == value:

        option.click()

        break

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务