#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)
''' from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys import time,os
import random # about:addons 火狐浏览器安装组件,访问的地址 # <input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off">
#id
keys="测试部落"
delay=3
url="https://www.baidu.com/"
url="file:///D:/ideaSpace/autoProject/python_autotest/nicetime/webdriver/pop08.html"
url="file:///D:/ideaSpace/autoProject/python_autotest/nicetime/webdriver/box08.html"
url="file:///D:/ideaSpace/autoProject/python_autotest/nicetime/webdriver/table08.html"
driver=webdriver.Firefox() #弹出框 主要分 alert confirm prompt
#主要的方法有 获取文本值:text 输入内容:send_keys 取消:dismiss 确定:accept driver.get(url)
time.sleep(delay) #单选按钮操作
driver.find_element_by_id("boy").click() #判断选择的状态
flag=driver.find_element_by_id("girl").is_selected()
print(flag) #复选框操作
boxs=driver.find_elements_by_xpath(".//*[@type='checkbox']")
for i in boxs:
i.click() #弹窗处理 alter confirm prompt
driver.find_element_by_id("alert").click()
driver.find_element_by_id("confirm").click()
driver.find_element_by_id("prompt").click()
time.sleep(delay) t=driver.switch_to_alert()
print(t.text) t.send_keys("需要输入你想要查看的")
#
t.accept
#
# t.dismiss() # 表格页面数据获取
# 里面的body要换成tbody 行和列中的值可按顺序获取值
t=driver.find_element_by_xpath(".//*[@id='mytable']/tbody/tr[2]/td[1]")
print(t.text) driver.quit()

Python3+Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)的更多相关文章

  1. Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )

    !/usr/bin/env python -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )'''from selenium im ...

  2. Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)'''from sel ...

  3. Python3+Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)'''from ...

  4. Python3+Selenium3+webdriver学习笔记11(cookie处理)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记11(cookie处理)'''from selenium im ...

  5. Python3+Selenium3+webdriver学习笔记10(元素属性、页面源码)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记10(元素属性.页面源码)'''from selenium i ...

  6. Python3+Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)'''from seleni ...

  7. 《jquery权威指南2》学习笔记------ jquery获取复选框的值

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  8. Python3+Selenium3+webdriver学习笔记7(选择多链接的结果、iframe、下拉框)

    #!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...

  9. Python3+Selenium3+webdriver学习笔记6(多窗口切换处理)

    #!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...

随机推荐

  1. va_list函数学习

    当你的函数的参数个数不确定时,就可以使用上述宏进行动态处理,这无疑为你的程序增加了灵活性. va_list的使用方法: a)  首先在函数中定义一个具有va_list型的变量,这个变量是指向参数的指针 ...

  2. MVN&nbsp;命令行

    Maven依赖查询: http://mvnrepository.com/ Maven常用命令:  1. 创建Maven的普通java项目:     mvn archetype:create     - ...

  3. HDU 3549 Flow Problem (最大流ISAP)

    Flow Problem Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tota ...

  4. 软件工程作业——Word Counter

    github地址 https://github.com/Pryriat/Word_Counter 项目说明 wc.exe 是一个常见的工具,它能统计文本文件的字符数.单词数和行数.这个项目要求写一个命 ...

  5. 在 Ubuntu 上安装 Protobuf 3

    什么时候需要安装 如果使用 protoc 命令,遇到 Protoc not found,表示未安装.或者,执行时出现错误:This parser only recognizes "proto ...

  6. CSS 绝对定位与相对定位的区别

    设置为绝对定位的元素框从文档流完全删除, 并相对于其包含块定位,包含块可能是文档中的另一个元素或者是初始包含块. 元素原先在正常文档流中所占的空间会关闭,就好像该元素原来不存在一样. 元素定位后生成一 ...

  7. UGUI(七)界面拖动和焦点界面

    http://blog.sina.com.cn/s/blog_89d90b7c0102vj9e.html 一般软件和游戏有多窗口多界面时,都可以拖动子界面和排序子界面[点击后变成焦点界面显示在最前面] ...

  8. 浅谈Unity的渲染优化(1): 性能分析和瓶颈判断(上篇)

    http://www.taidous.com/article-667-1.html 前言 首先,这个系列文章做个大致的介绍,题目"浅谈Unity",因为公司和国内大部分3D手游开发 ...

  9. 关于通过angularJs将页面中的html table 导出生成excel

    直接上代码: <button class="btn btn-link" ng-click="exportToExcel('#table1')"> & ...

  10. [Xcode 实际操作]六、媒体与动画-(7)遍历系统提供的所有滤镜

    目录:[Swift]Xcode实际操作 本文将演示系统到底提供了多少滤镜供开发者使用,并了解每个滤镜都有哪些参数需要配置. 在项目导航区,打开视图控制器的代码文件[ViewController.swi ...