当 Selenium IDE 将 html 转换为 php 时,为什么它不创建简单的 Selenese 命令?
我正在使用:
- Selenium IDE 版本:1.0.10
- PHPUnit 3.4.15
如果我使用 Selenium IDE(firefox 插件)创建一个非常简单的测试用例,并在 Selenese 表行中使用一个命令:
waitForElementPresent | css=div
然后使用 Selenium IDE >选项>格式> PHP 功能将该代码转换为 PHP。
我得到这样的信息:
<?php
...
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
...
for ($second = 0; ; $second++) {
if ($second >= 60) $this->fail("timeout");
try {
if ($this->isElementPresent("css=div")) break;
} catch (Exception $e) {}
sleep(1);
...
}
我的问题是:
为什么 PHP 代码以如此复杂的方式生成?
我可以将该命令转换为如下内容:
<?php
...
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
...
$this->waitForElementPresent("css=div");
...
}
php 的后一行将利用父类中的魔术方法: PHPUnit_Extensions_SeleniumTestCase::__call($command, $arguments)
这背后的原因是什么有点复杂的 PHP 输出?
- 难道只是为了让PHP减少对PHPUnit的依赖吗?
- 是因为它是一个错误的补丁吗?
- 是因为它可以提供更好的测试结果反馈吗?
我问这个问题是因为我是一个硒新手,并且想知道是否有任何理由我不应该只用第二个代码示例(上面)的硒风格编写我的方法。
I am using:
- Selenium IDE version: 1.0.10
- PHPUnit 3.4.15
If I use Selenium IDE (the firefox plugin) to create a very simple test case, with one command in a Selenese table row:
waitForElementPresent | css=div
Then use the Selenium IDE > Options > Format > PHP
feature to convert that code into PHP.
I get something like:
<?php
...
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
...
for ($second = 0; ; $second++) {
if ($second >= 60) $this->fail("timeout");
try {
if ($this->isElementPresent("css=div")) break;
} catch (Exception $e) {}
sleep(1);
...
}
My question is:
Why is that PHP code generated in such a convoluted way?
I could convert that command into something like:
<?php
...
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
...
$this->waitForElementPresent("css=div");
...
}
The latter line of php would make use of the magic method in the parent class: PHPUnit_Extensions_SeleniumTestCase::__call($command, $arguments)
What is the reasoning behind this kind of convoluted PHP output?
- Is it just to make the PHP less reliant on PHPUnit?
- Is it because it is a patch on a bug?
- Is it because it gives better test result feedback?
I'm asking because I am a selenium newbie and am wondering whether there is any reason why I should not just write my methods in the selenese-style of that second code example (above).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有这些都是因为会发生以下错误而编写的:
例如,selenium 的代码在许多其他事情中都有超时......
All those are written because of bugs that will occur in:
For instance selenium's code have a timeout among lot of other things...