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).
All those are written because of bugs that will occur in:
$this->waitForElementPresent("css=div");
For instance selenium's code have a timeout among lot of other things...
精彩评论