使用selenium和planterbox进行web测试的步骤

planterbox-webdriver的Python项目详细描述


https://api.travis-ci.org/npilon/planterbox-webdriver.png?branch=master

一套台阶 planterbox用于web测试 含硒

用法

  1. 安装planterboxplanterbox-webdriverpip install planterbox planterbox-webdriver

  2. unittest.cfg添加到启用planterbox

    [unittest]
    plugins = planterbox
    
    [planterbox]
    always-on = True
    

三。创建一个包含测试的包;它的__init__.py定义了在.feature文件中可用的步骤。 此包必须由nose2检测为包含测试;请参阅nose2’s docs for details

  1. 添加一个“before”挂钩,为您的测试设置一个网络驱动程序:

    @hook('before', 'feature')
    def create_webdriver(test):
        from selenium import webdriver
        test.browser = webdriver.Firefox()
    
  2. from planterbox_webdriver.webdriver import *如果您想要使用xpath在测试中查找元素的步骤

  3. from planterbox_webdriver.css_selector_steps import *用于使用jquery样式的css选择器在测试中查找元素的步骤

  4. 在此包中添加一个.feature文件,其中包含使用Gherkin指定的测试。planterbox将把它们转换成适当的测试用例对象,并将它们交给nose运行。

  5. 运行测试:nose2

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
添加组件后,java JTable为空   java将json发送到php并插入mysql,但返回null   java Spring引导JNDI CommonJ资源   从不同PC创建和合并后的Java servlet问题   java如何在使用findelements时从xpath获取文本   java使用spring boot使用gmail smtp发送电子邮件   java在不使用pojo、bean或getter和setter的情况下获取Json标题的Json数组   Java中的OpenFile对话框将null作为响应   JavaBuilder模式。扩展接口   java中无需替换的数据结构选取   java如何评价Encog中的预测神经网络   java如何在安卓中使用实际的HttpURLConnection进行单元测试?   java使用XML配置禁用WebSocket中的CSRF保护   java如何通过hibernate从多表查询中获取数据?   mysql如何在java中获取更新的行Id   java AEM/CQ组件单一组件/有限组件   java FFmpeg Javacv延迟问题   显示整数数组的java不起作用