selenium+python笔记8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@desc: 定制浏览器
"""
import unittest
import os
import time from selenium import webdriver class TestConfigFirefox(unittest.TestCase):
def setUp(self):
fp = webdriver.FirefoxProfile() # 在Firefox地址栏中输入about:config,查看相关配置属性
fp.set_preference("browser.download.folderList", 2)
fp.set_preference("browser.download.manager.showWhenStarting", False)
fp.set_preference("browser.download.dir", os.getcwd())
fp.set_preference("browser.helperApps.neverAsk.saveToDisk",
"application/octet-stream") # 下载文件的类型 self.driver = webdriver.Firefox(firefox_profile=fp)
self.driver.maximize_window()
self.driver.implicitly_wait(30)
self.base_url = "http://www.baidu.com"
self.verificationErrors = [] def test_baidu(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_id("kw").clear()
driver.find_element_by_id("kw").send_keys("unittest")
driver.find_element_by_id("su").click()
time.sleep(2)
title = driver.title
self.assertEqual(title, u"unittest_百度搜索") def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors) if __name__ == "__main__":
unittest.main()
selenium+python笔记8的更多相关文章
- selenium+python笔记11
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: search in mail box "&qu ...
- selenium+python笔记10
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 我们多添加一些测试场景,比如:删除邮件,查找邮件,发送邮件等等 &qu ...
- selenium+python笔记9
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: delete mail 我们多添加一些测试场景,比如:删 ...
- selenium+python笔记7
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: 测试126邮箱的登陆功能 1.使用公共方法public. ...
- selenium+python笔记6
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: 将登陆动作封装成function "" ...
- selenium+python笔记5
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: 登陆126邮箱 """ f ...
- selenium+python笔记4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: 使用unittest组织用例 ""& ...
- selenium+python笔记3
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc:学习unittest的用法 注意setUp/setUpCl ...
- selenium+python笔记2
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: 操作浏览器 """ fro ...
随机推荐
- number_format
number_format — 以千位分隔符方式格式化一个数字 说明 string number_format ( float $number [, int $decimals = 0 ] ) str ...
- Shell脚本编程初体验
原文:http://linoxide.com/linux-shell-script/guide-start-learning-shell-scripting-scratch/ 作者: Petras L ...
- Cheatsheet: 2014 01.01 ~ 01.14
.NET 15 reasons why I can't work without JetBrains ReSharper Web Web scraping with Node.js Koa.js : ...
- php中一个"异类"语法: $a && $b = $c;
php中一个"异类"语法: $a && $b = $c; $a = 1;$b = 2;$c = 3;$a && $b = $c;echo & ...
- matplotlib
前导: 安装 numpy http://sourceforge.net/projects/numpy/files/ http://sourceforge.net/projects/numpy/file ...
- NSKeyedArchive(存储自定义对象)
在viewController.m中: - (void)viewDidLoad { [super viewDidLoad]; ZWPerson *p = [[ZWPerson alloc] init] ...
- 【网络流24题----03】Air Raid最小路径覆盖
Air Raid Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- DataGridView常用操作
一.DataGridView列右击菜单事件处理 (1). 添加一个快捷菜单contextMenuStrip1:(2). 给dataGridView1的CellMouseDown事件添加处理程序: pr ...
- 纯js写验证码
<html> <head> <meta name="viewport" content="width=device-width" ...
- spring对事物的支持
<!-- 事务管理器 对mybatis操作数据库事务控制,spring使用jdbc的事务控制类 --> <bean id="transactionManager" ...