从 selenium 测试脚本回到 selenese
我有一堆使用 Test::WWW::Selenium 编写的测试脚本(但我使用 perl 的事实并不重要,selenium 支持的任何语言都可能存在我描述的问题)。当我的应用程序中的齿轮松动时,我想使用 Selenium IDE 重播测试,让我完全控制操作
但我不确定如何从我的测试脚本返回到 selenium IDE,您可以不要将 Perl 粘贴到 IDE 中并将其转换回“HTML”(又名内部 selenium 语言,又名 selenese)。唉,把它拿出来很容易。
RemoteRunner 中有命令历史记录,我可以将其直接复制并粘贴到 selenium ide 中,那太好了,但历史记录框只能保存 5 或 6 行并自行清除!所以它嘲笑我并且毫无用处。
那么如何更有效地记录这些呢? selenium rc 的日志记录选项(-browserSideLog、-log)在这方面似乎没有帮助。我正在考虑找到它的 RemoteRunner.html 并对其进行黑客攻击,这样它就不会清除该列表,但是还有其他方法吗?
I've got a bunch of test scripts written using Test::WWW::Selenium (but the fact that I used perl is inconsequential, any language selenium supports probably has the problem I describe). When the cogs in my application come loose I'd like to replay the test using the Selenium IDE, letting me have full control over the action
But I'm not sure how to go from my test script back into the selenium IDE, you can't paste perl into the IDE and have it transmogrify back to "HTML" (aka, internal selenium language, aka selenese). It was easy enough getting it out, alas.
The RemoteRunner has the command history in it, and I can copy and paste from this directly into selenium ide, and that would be great, but the history box will only hold 5 or 6 lines and clears itself! So it taunts me and is useless.
So how to log these more effectively? The logging options for the selenium rc (-browserSideLog, -log) don't seem to be helpful in this regard. I'm thinking of finding its RemoteRunner.html and hacking at it maybe so it won't clear that list, but is there another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这似乎是一项不太常见的任务,但却非常有趣。我不认为有某种标准方法必须实施。
我不太了解 Perl,并且使用 Java,所以这只是一个提示:
我将为我的测试扩展
DefaultSelenium
类,该类将使用扩展的HttpCommandProcessor
来记录执行的所有命令:然后
我将扩展 SeleneseTestCase 用作我的测试的基础:
import com.thoughtworks.selenium.SeleneseTestCase;
此类测试的输出将如下所示:
此解决方案不会记录
verify
和assert
,因此它们也可能在 ExSeleneseTestCase 中被覆盖以产生一些跟踪。It seems to be a not very common task but very interesting one. I do not think that there's some standard way so something has to be implemented.
I do not know Perl much and I use Java, so this is just a heads up:
I would extend the
DefaultSelenium
class for my tests that will use extendedHttpCommandProcessor
that will logs all commands performed:And
Then I would extend
SeleneseTestCase
for use as the base in my tests:import com.thoughtworks.selenium.SeleneseTestCase;
The output of such test will look like:
This solution will not log
verify
s andassert
s so they may also be overrided in ExSeleneseTestCase to produce some trace.您也可以采取另一种方式,这可能更容易:在生成(部分)selenese HTML 文件时保存它们,并从 perl/java/... 代码中解析文件并使用 doCommand 执行行。这样,您就不必重建断言/验证语句,因为它们一开始就没有丢失。
You could also go the other way, which is probably easier: save the (partial) selenese HTML files when you generate them, and from the perl/java/... code, parse the files and execute the lines using doCommand. That way, you don't have to reconstruct the asserts/verify statements, because they weren't lost in the first place.