python+selenium初级(8)—提示框处理
来源:互联网 发布:浙江卫视直播软件 编辑:程序博客网 时间:2024/06/05 20:07
在WebDriver 中处理JavaScript 所生成的alert、confirm 以及prompt 是很简单的。
使用switch_to_alert()方法定位到alert/confirm/prompt,然后使用text/accept/dismiss/send_keys 按需进行操做。
text 返回提示框中的文字信息
accept 点击确定按钮
dismiss 点击取消按钮
#coding=utf-8from selenium import webdriverimport timefrom selenium.webdriver.common.action_chains import ActionChainsdriver = webdriver.Firefox()driver.get('http://www.baidu.com')#打开设置中的搜索设置ActionChains(driver).move_to_element(driver.find_element_by_link_text(u'设置')).perform() #鼠标悬浮于设置driver.find_element_by_link_text(u'搜索设置').click() #点击搜索设置driver.find_element_by_link_text(u'保存设置').click() #保存设置弹出提示框driver.switch_to_alert().accept() #点击确定按钮driver.quit()
阅读全文
0 0
- python+selenium初级(8)—提示框处理
- python+selenium初级(1)—控制浏览器
- python+selenium初级(2)—简单元素的操作
- python+selenium初级(3)—WebElement接口常用方法
- python+selenium初级(7)—多窗口切换
- python+selenium初级(9)—文件上传
- python+selenium初级(10)—八大定位方法
- python+selenium初级(4)—selenium中对于鼠标的操作
- python+selenium初级(5)—selenium中快捷键的操作
- python+selenium初级(6)—通过切换iframe定位元素
- selenium-webdriver(python)-- 处理下拉框
- phantomjs selenium python 提示错误
- selenium-webdriver(python) -- cookie处理
- Python学习笔记-初级(四):文件处理
- selenium+webdriver+python 中警告框的处理方法
- 基于python的selenium实现警告框的处理
- 网页处理实践(2)——Uubntu上python+Selenium+Firefox
- 网页处理实践(3)——python+selenium+firefox,不弹出窗口,静默模式运行
- dql数据权限控制
- HTML5新增语义元素
- Linux userdel 和 deluser 的区别
- Qml文件的两种加载方式
- shell脚本嵌套if else
- python+selenium初级(8)—提示框处理
- 根据 Google-speed 的优化网页速度
- 2017 Google 开发者大会全记录
- MySQL必知必会
- cglib初步使用代理
- Linux useradd 和 adduser 的区别
- Android中级篇之Fresco-加载图片基础[详细图解Fresco的使用]
- JS的解析与执行——函数预处理与执行
- 虚拟机上网设置