基于python的selenium实现警告框的处理
2016-07-12 11:03
1521 查看
#coding=UTF-8
'''
Created on 2016-7-8
@author: sun
'''
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time
driver=webdriver.Firefox()
driver.implicitly_wait(10)
driver.get("http://www.baidu.com")
#鼠标悬停至设置链接
link=driver.find_element_by_link_text(u"设置")
ActionChains(driver).move_to_element(link).perform()
#打开搜索设置
driver.find_element_by_link_text(u"搜索设置").click()
#保存设置
driver.find_element_by_class_name("prefpanelgo").click()
time.sleep(2)
#接受警告框
driver.switch_to_alert().accept()
driver.quit()
'''
Created on 2016-7-8
@author: sun
'''
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time
driver=webdriver.Firefox()
driver.implicitly_wait(10)
driver.get("http://www.baidu.com")
#鼠标悬停至设置链接
link=driver.find_element_by_link_text(u"设置")
ActionChains(driver).move_to_element(link).perform()
#打开搜索设置
driver.find_element_by_link_text(u"搜索设置").click()
#保存设置
driver.find_element_by_class_name("prefpanelgo").click()
time.sleep(2)
#接受警告框
driver.switch_to_alert().accept()
driver.quit()
相关文章推荐
- python: DOM 小实例
- python 学习第二篇 排序
- 各大推荐引擎 整理
- 4000 基于python的selenium实现多窗口切换
- python学习知识点记录
- Python新手学习基础之数据类型——变量
- 廖雪峰python学习笔记9:面向对象高级
- 廖雪峰python学习笔记8:面向对象初步
- 廖雪峰python学习笔记7:函数
- 廖雪峰python学习笔记6:条件判断、循环
- 廖雪峰python学习笔记5:编码
- 廖雪峰python学习笔记4:高级特性
- Python开发: DOM
- Python学习笔记:Python函数
- 廖雪峰python学习笔记3:dec和set
- 廖雪峰python学习笔记2:表
- 廖雪峰python学习笔记1:hello python
- Python 脚本获取上一个工作日的方法
- Python序列化模型数据为JSON
- pandas 新手指引