#!/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操作应用:弹出框无效如何处理)的更多相关文章

  1. Python3+Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记8(单选.复选框.弹窗处理)''' from selenium ...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  9. Python3+Selenium3+webdriver学习笔记5(模拟常用键盘和鼠标事件)

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

随机推荐

  1. 转载:数据库应用开发工具Toad使用笔记

    由于网上TOAD中文教程很少,在网上摘抄了此文章便于学习,感谢原创者. TOAD使用笔记 1.把鼠标停在sql所在行,然后ctrl+Enter直接执行当前sql. 2.解决Toad对中文显示乱码问题( ...

  2. python的paramiko模块的安装与使用

    一:简介 paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接. 由于使用的是python这样的能够跨平台运行的语言,所以所有python支 ...

  3. Adding In-App Purchase to your iOS and OS X Applications

    Adding In-App Purchase to your iOS and OS X Applications In-App Purchase allows you to sell addition ...

  4. iOS证书和描述文件的配置

    1.登录Apple开发者账号,进入Apple Developer主页,点击Account 2.点击Certificates,ID&Profiles 3.生成CRS文件 1.打开mac上的钥匙串 ...

  5. python 学习笔记8 (模块)

    Python 模块(Module),是一个 Python 文件,以 .py 结尾,包含了 Python 对象定义和Python语句. 模块让你能够有逻辑地组织你的 Python 代码段. 把相关的代码 ...

  6. MapReduce编程模型

    # 文本前期处理 strl_ist = str.replace('\n', '').lower().split(' ') count_dict = {} # 如果字典里有该单词则加 1,否则添加入字典 ...

  7. 2014 Noip提高组 Day1

    P1328 生活大爆炸版石头剪刀布 [题目描述] 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一样,则不分胜负.在<生活大爆炸>第二季第8 集中出现了一种石头 ...

  8. IT兄弟连 Java语法教程 Java语言背景

    驱使计算机语言革新的因素有两个:程序设计技术的改进和计算环境的改变.Java也不例外.在大量继承C和C++的基础之上,Java还增加了反应当前程序设计技术状态的功能与精华.针对在线环境的蓬勃发展(In ...

  9. Netty源码分析(七):初识ChannelPipeline

    ChannelPipeline单看名称就可以知道Channel的管道.本篇将结合它的默认实现类DefaultChannelPipeline来对它做一个简单的介绍. 示例图 上图是官方提供的Channe ...

  10. web前端篇:CSS使用,样式表特征,选择器

    目录 web前端篇:CSS使用,样式表特征,选择器 1.CSS介绍 2.CSS使用 3.样式表特征 4.CSS选择器 5.选择器的优先级 6.练习题: web前端篇:CSS使用,样式表特征,选择器 1 ...