#!/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. strTemp.Format ("%.*lf",3,600.0);

    CString strTemp; strTemp.Format ("%.*lf",3,600.0); 这句话的含义?求指教   优质解答 这就是一个格式化输出,分号之前的CStri ...

  2. 4.ctf实战题

    一道ctf实战题. 先亮出网址: http://fb2ad00f-0a28-4e38-8fff-849d7391e2d0.coding.io 打开连接,看到下面页面.Web题,首先就是扫描(御剑啊还有 ...

  3. php中使用mysqli和pdo扩展,测试连接mysql数据库的效率。

    <?php /** * 测试pdo和mysqli的连接效率,各连接100次mysql数据库 */ header("Content-type:text/html;charset=utf8 ...

  4. tcpkill工作原理分析

    此文已由作者张耕源授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 日常工作生活中大家在维护自己的服务器.VPS有时会碰到这样的情况:服务器上突然出现了许多来自未知ip的网络连 ...

  5. VS 远程部署程序

    第1步 https://www.cnblogs.com/hydor/p/6604053.html 第2步 http://www.cnblogs.com/potential/p/3751426.html ...

  6. MYSQL limit,offset 区别(转)

    SELECT keyword FROM keyword_rank WHERE advertiserid='59' order by keyword LIMIT 2 OFFSET 1; 比如这个SQL ...

  7. Unity命令行打包

    http://www.66acg.com/?post=137 补充 unity编辑器端获取打包命令行自定义参数,这个可以获取到所有打包时的参数 string[] runArgs = System.En ...

  8. Hyperledger Fabric 替换couchDB

    fabric中默认数据存储的方式是levelDB,一个key/value存储的单机数据库.除此之外还提供了另外一种存储方式:couchDB.同样也是一个K/V 数据库,对fabric而言,相比于前者, ...

  9. 2014 Noip提高组 Day2

    P2038 无线网络发射器选址 [题目描述] 随着智能手机的日益普及,人们对无线网的需求日益增大.某城市决定对城市内的公共场所覆盖无线网. 假设该城市的布局为由严格平行的129 条东西向街道和129 ...

  10. Google Analytics & Webtrend 使用笔记

    GA和webtrend中的参数,每每遇到了都记不住.遇到一点记一点好了... Page Views(PV): 浏览次数.用户每打开一个页面,记录为1个PV:用户多次打开同一个页面,PV累计多次. Da ...