我正在使用Selenium IDE 2.3.0在我的Web应用程序中记录操作并创建测试。
在每次测试之前,我必须清除所有cookie,加载主页面,与特定用户一起登录并提交登录表单。 这些~10个命令是固定的,每个测试用例都需要它们,但我不想每次都从其他测试中记录或复制它们。
有没有办法配置如何创建“空”测试用例?
我知道我可以创建一个prepare.html文件或其他东西,并将其添加到测试套件中。 但我需要能够同时运行单个测试或所有测试,因此每个测试用例都必须包含命令。
I'm using Selenium IDE 2.3.0 to record actions in my web application and create tests.
Before every test I have to clear all cookies, load the main page, log in with a specific user and submit the login form. These ~10 commands are fix and every test case needs them, but I don't want to record or copy them from other tests every time.
Is there a way to configure how "empty" test cases are created?
I know I could create a prepare.html file or something and prepend it to a test suite. But I need to be able to run either a single test or all tests at once, so every test case must include the commands.
最满意答案
Selenium支持面向对象的设计。 您应该创建一个类,该类接受您引用的那些命令并始终执行这些命令,在您执行的每个测试中,您可以调用该类和支持方法然后执行它。
这是一个很好的资源。
Ok I finally came up with a solution that suits me. I wrote custom commands setUpTest and tearDownTest, so I only have to add those two manually to each test.
I used this post to get started: Adding custom commands to Selenium IDE
更多推荐
发布评论