再django中应用selenium做测试
来源:互联网 发布:梦幻西游物价软件 编辑:程序博客网 时间:2024/06/05 09:36
Setup the selenium test environment in Django:
1. install seleniumpip install selenium
2. write some test code
create a test file called 'tests' in a file called 'testsfile'
the Helpful URL part below contains some nice code, try some sample in your tests
3. change the setting file to use a stable test database
(1) create a test database, use a computer enviornment variable which called TEST_DB to make sure only when TEST_DB=1 execute the test database.
import os(this line should put at the top of setting file)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME':
'USER':
'PASSWORD':
'HOST': 'localhost',
'PORT': '',
'TEST_MIRROR': 'default',
}
}
(2) make sure the test database have the same table and attribute with your product database
4. run the test case
TEST_DB=1 ./manage.py test
5. use the chrome to be the webdriver
errors:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH
solution:
add path like this:
driver = webdriver.Chrome("C:/Users/michael/Downloads/chromedriver_win32/chromedriver.exe")
besides, firefox have the webdriver in itself, if you want to use chrome you need to install chromedriver manully go to http://chromedriver.storage.googleapis.com/index.html
download the chromedriver
in ubuntu, I use the following process(not sure if it is same in Mac and windows):
1. extract the chromedriver
2. move it to the /usr/bin file
3. use the following command
chmod a+x chromedriver
to make sure it could be execute.
Helpful URL
http://selenium-python.readthedocs.org/navigating.html
Attention
all selenium test function should start with "test_"
0 0
- 再django中应用selenium做测试
- 使用Selenium/Ant做Web应用远程自动化测试
- Selenium Grid2做分布式测试
- 用Selenium测试web应用
- 用Selenium测试web应用
- 用Selenium测试web应用
- 用Selenium测试web应用
- Selenium+PhantomJS自动化测试应用
- 如何用Selenium做自动化测试
- Selenium + Java 做 WEB GUI 自动化测试中提升代码质量的方法
- 用Selenium RC插件测试远程应用
- Selenium实例:AJAX自动化测试应用
- 在Android上应用Selenium进行测试
- python 自动化测试脚本-->selenium应用
- Django中编写测试程序
- IronPython应用之Selenium(Web测试,AutoPyTest自动化测试)
- 使用Selenium或appium做 Android自动化测试
- django中flatepages简单应用
- 一些不错的网站
- LeetCode 题解(190): Implement Queue using Stacks
- Win7系统与它的Virtualbox中安装的Ubuntu14.04共享信息的几种方法
- C中的常见库文件说明
- regex
- 再django中应用selenium做测试
- 一个93年弱鸡程序员来到深圳深入简出
- POJ 1141 解题报告
- [人月神话]读书笔记7--产品品质保障&&日常进度跟踪
- [人月神话]读书笔记8--软件产品需要的文档&&软件开发没有银弹(捷径)
- Android Api Demos登顶之路(四十)Fragment-->Layout
- 【LeetCode-面试算法经典-Java实现】【153-Find Minimum in Rotated Sorted Array(找旋转数组中的最小数字)】
- 【LeetCode-面试算法经典-Java实现】【154-Find Minimum in Rotated Sorted Array II(找旋转数组中的最小数字II)】
- 【LeetCode-面试算法经典-Java实现】【155-Min Stack(最小栈)】