Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)
- #!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)
'''
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
import time,os- # about:addons 火狐浏览器安装组件,访问的地址
- # <input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off">
#id
keys="设置"
delay=3
url="https://www.baidu.com/"
driver=webdriver.Firefox()- driver.get(url)
- mouse=driver.find_element_by_link_text(keys)
ActionChains(driver).move_to_element(mouse).perform()
time.sleep(delay)- driver.find_element_by_link_text("搜索设置").click()
time.sleep(delay)- # <select name="NR" id="nr">
# <option value="10" selected="">每页显示10条</option>
# <option value="20">每页显示20条</option>
# <option value="50">每页显示50条</option>
# </select>- se=driver.find_element_by_id("nr")
Select(se).select_by_index(2)- #一般方式
# <div id="gxszButton"><a href="#" class="prefpanelgo">保存设置</a><a href="#" class="prefpanelrestore">恢复默认</a></div>
driver.find_element("id","gxszButton").click()
driver.find_element("class name","prefpanelgo").click()- #脚本方式
js='document.getElementsByClassName("prefpanelgo")[0].click();'
driver.execute_script(js)- driver.quit()
Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)的更多相关文章
- Python3+Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记8(单选.复选框.弹窗处理)''' from selenium ...
- Python3+Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)'''from ...
- Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )
!/usr/bin/env python -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)'''from seleni ...
- 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学习笔记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 ...
- Python3+Selenium3+webdriver学习笔记5(模拟常用键盘和鼠标事件)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
随机推荐
- 条款32:确定你的public继承塑模出is-a的关系
Make sure public inheritance models "is –a " 如果令clsss D 以public的形式继承class B,你便是告诉编译器说,每一个类 ...
- 通过bed文件获取fasta序列
一.BED 文件格式 BED 文件格式提供了一种灵活的方式来定义的数据行,以用来描述注释的信息.BED行有3个必须的列和9个额外可选的列. 每行的数据格式要求一致. 必须包含的3列: 1.chrom, ...
- 24.集成ASP.NETCore Identity
正常的情况下view页面的错误的显示应该是这么去判断的 这里我们就不加判断为了,直接用这个div 显示就可以了.当有错误会自动显示在div内 asp.net core Identity加入进来 这里用 ...
- ASP.NET中 TextBox 文本输入框控件的使用方法
TextBox控件又称文本框控件,为用户提供输入文本的功能. 1.属性 TextBox控件的常用属性及说明如表1所示. 表1 TextBox控件常用属性及说明 属性 说明 AutoPostBack 获 ...
- 【转】springmvc @RequestParam
在SpringMVC后台控制层获取参数的方式主要有两种,一种是request.getParameter("name"),另外一种是用注解@RequestParam直接获取.这里主要 ...
- 判断ip地址是否为内网ip或局域网ip
bool IsLanIp(string& ip) { ,) == ,) == ,) == "192.") { return true; } else { return fa ...
- 大话Spark(1)-Spark概述与核心概念
说到Spark就不得不提MapReduce/Hadoop, 当前越来越多的公司已经把大数据计算引擎从MapReduce升级到了Spark. 至于原因当然是MapReduce的一些局限性了, 我们一起先 ...
- ApplicationContext的三个常用实现类:
ClassPathXmlApplicationContext 它可以加载类路径下的配置文件,要求配置文件必须在类路径下,不在的话加载不了 (java中获取类路径下资源的方式) FileSystemXm ...
- Solr6.7 学习笔记(01) -- 目录结构
Solr解压后的目录结构 --contrib: Solr的一些扩展 --analysis-extras: 包含一些文本分析组件及其依赖 --clustering: 包含一个用于集群搜索结果的引擎 -- ...
- docker中容器和镜像的区别
自学docker过程中一直搞不明白 镜像容器的关系,网上查阅看到一篇文章觉得讲的很好,转载记录. 转自 http://blog.csdn.net/chszs/article/details/48252 ...