zoukankan      html  css  js  c++  java
  • Selenium 入门到精通系列:六

    Selenium 入门到精通系列


    PS:Checkbox方法

    例子

    HTML:

    <html>
    <head>
    <title>测试页面</title>
    </head>
    <body>
    <form action="" method="get">您喜欢的水果?<br /><br />
    <label><input name="Fruit" type="checkbox" value="" />苹果 </label>
    <label><input name="Fruit" type="checkbox" value="" />桃子 </label>
    <label><input name="Fruit" type="checkbox" value="" />香蕉 </label>
    <label><input name="Fruit" type="checkbox" value="" /></label>
    </form>
    </body>
    </html>
    

    代码:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Date    : 2019-04-23 16:12:33
    # @Author  : BenLam
    # @Link    : https://www.cnblogs.com/BenLam/
    
    from selenium import webdriver
    driver=webdriver.Firefox()
    driver.get('test.html')
    
    #选中所有的tag name为input的元素
    inputs=driver.find_elements_by_tag_name('input')
    
    #for循环勾选
    for i in inputs:
        if i.get_attribute('type')=='checkbox':
            i.click()
    driver.quit()
    
    
  • 相关阅读:
    iOS基础
    iOS基础 ----- 内存管理
    NSAttributedString 的一些基本用法
    node安装使用
    docker常用命令
    docker lnmp
    easy-wechat
    composer
    center7系统搭建lnmp
    xammp环境配置
  • 原文地址:https://www.cnblogs.com/BenLam/p/10760951.html
Copyright © 2011-2022 走看看