一个设置就绪的selenium rc环境的方法

rcom.recipe.seleniumenv的Python项目详细描述


Detailed Documentation

Watch the screencast!

Supported options

配方支持以下选项:

硒离子浓度
要使用的硒版本,版本号可以从 http://release.seleniumhq.org/selenium-remote-control/。默认值:NightlyBuild。
鸡蛋
要包含在流道中的鸡蛋。路径中包含的任何产品都将是 跑步者可以从中搜索和运行硒测试。
Java命令
用于运行Selenium服务器的命令。默认值:Java。

Example usage

使用配方的基本构建应该如下所示:

>>> write('buildout.cfg',
... """
... [buildout]
... parts = seleniumenv
...
... [seleniumenv]
... recipe = rcom.recipe.seleniumenv
... seleniumversion = 1.0-beta-2
... eggs = ${instance:eggs}

The seleniumrunner script

selenium runner是一个用于查找和运行selenium测试的脚本,它将 一旦配方安装好就在bin目录中 它接收不同的参数,其主要目的是简化 测试执行和报告程序。 此脚本将唤醒selenium rc服务器,搜索并运行测试 然后关闭服务器并报告测试结果。 配方安装完成后,应在垃圾箱上放置一个测试运行器 目录

Running the tests

要运行与任何产品捆绑在一起的测试套件,在 已经运行的构建是准备一个plone站点进行测试(如果用户 还没有一个plone站点来测试)。 要完成此操作,必须首先唤醒实例:

./bin/instance start

要运行产品的所有硒测试,用户至少应该通过两个 参数:

-i instanceThe Plone site’s name.
-s productThe product in which the runner will search for tests to run.

测试执行示例如下:

$ ./bin/seleniumrunner -i testPloneSite -s namespace.product

这将搜索产品的所有selenium测试并运行它们 在http://localhost:<;端口已使用>;/testplonesite上。

对于运行特定测试,-t参数应传递给运行程序:

$ ./bin/seleniumrunner -i testPloneSite -s namespace.product -t exampleTest

注意

请注意exampletest.py测试应该存储在 各自的位置并添加到初始py文件中(请参见Creating a test

Creating a test

seleniumrunner脚本将查找从 位于这种类型下的指定包或模块上的unittest.testcase 路径:

namespace.product/namespace/product/tests/seleniumtests
Tests development guidelines

要创建测试,需要遵循一些基本规则:

  1. 测试应该继承自unittest.testcase类(可以这样做 也间接地)。

  2. 测试应该使用某些全局变量使代码工作 在不同的环境和扑通声中。这些是:

    • browser: For the browser used for the tests
    • port: For the port used to communicate with the server
    • url: For the url of the application under test
    • instance: The Plone site name (this depends on the name used for the site’s creation).

在测试代码中不应更改此变量,因为 seleniumrunner脚本将在运行时根据参数设置它们 收到。

所有这些规则都可以应用于下面的Example test

Example test

下面是一个示例测试,它可以用作 未来测试的结构:

from selenium import selenium
import unittest

class NewTest(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", port, browser, url)
        self.selenium.start()

    def test_new(self):
        sel = self.selenium
                        sel.open(instance + "/login.html")
        # Do specific tests in here

    def tearDown(self):
        self.selenium.stop()
        self.assertEqual([], self.verificationErrors)

注意,测试与使用 Selenium IDE,火狐扩展。这个 唯一的区别是用于在setup中实例化的变量 方法。

注意

请注意,“instance”变量必须用于 每个open命令用于用户提供正确的位置 要测试的plone站点。

Contributors

圣地亚哥苏亚雷斯奥多尼兹,作者 Juan Pablo Gimenez,撰稿人

Change history

0.1 (2009-01-05)

  • Created recipe with ZopeSkel [Santiago Suarez Ordoñez].

1.0 (2009-02-14)

  • Ended code changes and uploaded the egg to pypi [Santiago Suarez Ordoñez].

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

推荐PyPI第三方库


热门话题
java web爬虫:使用selenium+webdriver遍历页面链接时出现两种异常   java JPA和SYS_REFCURSOR-like OUT参数   非空参数的java方法引用?   xml中的java子节点名称   java为什么GC不在同一个方法中运行   java如何检查可执行JAR是否已在另一个JVM中完成   将外观更改为Nimbus后出现jtable Java错误   用户界面Java Swing架构问题?   java导入自定义字体时我做错了什么?   java如何用API制作可伸缩的游戏策划   java玩家和方块的碰撞和交集   java增强的for循环   java propertiesmavenplugin不适用于目标writeprojectproperties   java循环返回代码的开头   java使用分号执行apachecommonsexec多个命令   Wicket应用程序中的java全局可访问资源   java在eclipse中设置参数时可以使用类名而不是id吗?   eternal和maxElementsInMemory在ehcache中的java角色?   java ClassCastException在同一个ear中从两个不同的WAR加载同一个类时,由于类装入器不同