#!/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. 最小化安装linux CentOS-6.6后 部署fastdfs +下载地址 很干很干的干货

    参考:http://blog.itpub.net/7734666/viewspace-1292485/ 安装一些必要软件 yum -y install wget gcc perl mkdir ~/zy ...

  2. C#开发Activex控件(转载别人的只为再看时方便放在自己里边了)

    前言 ActiveX控件以前也叫做OLE控件,它是微软IE支持的一种软件组件或对象,可以将其插入到Web页面中,实现在浏览器端执行动态程序功能, 以增强浏览器端的动态处理能力.通常ActiveX控件都 ...

  3. Bind 远程连接DNS服务器时出现 rndc: connection to remote host closed

    使用命令:rndc -s 192.168.1.2 status 连接远程的bind 搭建的DNS服务器时出现下面的错误:   rndc: connection to remote host close ...

  4. Spring入门第十九课

    后置通知 看代码: package logan.study.aop.impl; public interface ArithmeticCalculator { int add(int i, int j ...

  5. UVa 10534 Wavio Sequence (LIS+暴力)

    题意:给定一个序列,求一个最长子序列,使得序列长度为奇数,并且前一半严格递增,后一半严格递减. 析:先正向和逆向分别求一次LIS,然后再枚举中间的那个数,找得最长的那个序列. 代码如下: #pragm ...

  6. WCF大文件传输【转】

    http://www.cnblogs.com/happygx/archive/2013/10/29/3393973.html WCF大文件传输 WCF传输文件的时候可以设置每次文件的传输大小,如果是小 ...

  7. "Mysql has gone away"的几种可能

    现象: 在本地利用Flask自带的WSGI服务进行调试没有问题后,通过Gunicorn进行部署. 但是在一晚上没有访问之后,第二天再次访问会出现500(Internal error). 原因: 通过追 ...

  8. lightoj1009【DFS】

    思路: 连通快+二分图,每次+二分图大的元素个数. #include<bits/stdc++.h> using namespace std; typedef unsigned long l ...

  9. CodeForces - 820

    Mister B and Book ReadingCodeForces - 820A 题意:C,V0,V1,A,L..总共有C页书,第一天以V0速度读,每天加A,但是不能超过V1,并且要从前一天的看到 ...

  10. JS实现简单时钟效果

    老师上课需要我们做一个时钟的小作业 ,我把它放在上面记录一下啦 表盘和时针我都是用的背景图的形式,然后绝对定位,通过调整left和top确定时针.分针.秒针的位置,transform-origin设置 ...