使用selenium和planterbox进行web测试的步骤
planterbox-webdriver的Python项目详细描述
一套台阶 planterbox用于web测试 含硒
用法
安装planterbox和planterbox-webdriver:pip install planterbox planterbox-webdriver
将unittest.cfg添加到启用planterbox:
[unittest] plugins = planterbox [planterbox] always-on = True
三。创建一个包含测试的包;它的__init__.py定义了在.feature文件中可用的步骤。 此包必须由nose2检测为包含测试;请参阅nose2’s docs for details。
添加一个“before”挂钩,为您的测试设置一个网络驱动程序:
@hook('before', 'feature') def create_webdriver(test): from selenium import webdriver test.browser = webdriver.Firefox()
from planterbox_webdriver.webdriver import *如果您想要使用xpath在测试中查找元素的步骤
from planterbox_webdriver.css_selector_steps import *用于使用jquery样式的css选择器在测试中查找元素的步骤
在此包中添加一个.feature文件,其中包含使用Gherkin指定的测试。planterbox将把它们转换成适当的测试用例对象,并将它们交给nose运行。
运行测试:nose2