Python3+Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)
#!/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(单选、复选框、弹窗处理)的更多相关文章
- Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )
!/usr/bin/env python -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)'''from sel ...
- Python3+Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)'''from ...
- Python3+Selenium3+webdriver学习笔记11(cookie处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记11(cookie处理)'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记10(元素属性、页面源码)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记10(元素属性.页面源码)'''from selenium i ...
- Python3+Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)'''from seleni ...
- 《jquery权威指南2》学习笔记------ jquery获取复选框的值
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- Python3+Selenium3+webdriver学习笔记7(选择多链接的结果、iframe、下拉框)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
- Python3+Selenium3+webdriver学习笔记6(多窗口切换处理)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
随机推荐
- android TextView selector点击样式改变
1.selector 从单词的意思来说:选择器,就是对你的目标的控制.selector主要是用在ListView的item单击样式和TextView和Button的点击样式. 2.主要属性介绍: an ...
- 集成hibernateDaoSupport实现增删改查
1. package edu.jlu.fuliang.dao.impl; import java.util.List; import org.springframework.orm.hibernate ...
- 托管C++——在C#中使用C++
下面就用一个完整的实例来详细说明怎样用托管C++封装一个C++类以提供给C#使用. 现有一个Detector类需要使用,首先,要创建一个托管C++的DLL工程DAADll,然后在里面添加下面的代码: ...
- Spring:JdbcTemplate使用指南
Spring:JdbcTemplate使用指南 Spring:JdbcTemplate使用指南 前言: 本文指在介绍Spring框架中的JdbcTemplate类的使用方法,涉及基本的Spring反转 ...
- win+apache网站打开很慢的解决笔记
为了图方便,直接把wamp的vhost配置文件复制到新apache2.2.25上,结果打开静态页速度都非常慢. <VirtualHost *:> ServerAdmin www.fuck2 ...
- [翻译]Nativescript 中 Web 视图与 Android/IOS 的双向通信
English document From http://shripalsoni.com/blog/nativescript-webview-native-bi-directional-communi ...
- 推荐一款让你纵横Github的读码神器
当我们想深入了解一个开源项目的时候,通常我们有以下几种姿势: 懒汉型 通过Web的方式,逐个的点击页面寻找和查看具体的源码内容. 优点:不依赖任何工具,无须任何额外的操作 缺点:效率低下,查找文件不便 ...
- ue4 简单数据储存
- UE4 Runtime下动态给Actor添加组件
http://www.v5xy.com/?p=858 UE4的组件分为两种:USceneComponent, UActorComponent UActorComponent (NewObject(th ...
- Prefix.pch文件的用法
我们知道,每新建立一个工程,比如说HelloWord,在分类SupportingFiles里都会有一个以工程名开头-Prefix.pch结尾的文件,如HelloWord-Prefix.pch.对于这个 ...