zoukankan      html  css  js  c++  java
  • python selenium select标签的下拉框和非select标签的下拉框

    select标签的下拉框

     

    下拉框的选中

    from selenium import webdriver#导包
    from time import *
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.select import Select
    driver=webdriver.Chrome()#生成一个谷歌浏览器的操作对象
    driver.get('http://公司禅道ip/zentao/company-browse.html')
    driver.find_element_by_class_name('form-control').send_keys('用户名')#禅道账号
    driver.find_element_by_xpath('//*[@id="login-form"]/form/table/tbody/tr[2]/td/input').send_keys("密码")#禅道密码
    driver.find_element_by_id('submit').click()#点击登录
    id_elment='field4'
    WebDriverWait(driver,10,1).until(EC.visibility_of_element_located((By.ID,id_elment)))
    a=Select(driver.find_element_by_id('field4'))#定位select下拉框的位置
    a.select_by_index(1)#通过索引定位,第一个为0
    sleep(2)
    a.select_by_visible_text('用户名')#通过可见文本查找
    

    下拉框的取消选中

     

    a.deselect_by_index(1)
    a.deselect_by_visible_text('用户名')
    

     

    select标签的下拉框

    后续更新

     

  • 相关阅读:
    c++ this *this
    名称空间
    c++ 静态持续变量
    c++ 数组
    c++ 头文件
    实例化和具体化详解
    在linux下安装eclipse以及运行c++程序的安装步骤
    在centos (linux) 搭建 eclipse c++开发分环境
    Linux上使用Qt Creator进行C/C++开发
    使用Qt Creator 2.60编写C/C++程序
  • 原文地址:https://www.cnblogs.com/lly-lcf/p/13410791.html
Copyright © 2011-2022 走看看