I am using the PHPUnit_Selenium extension and encounter some unwanted behaviour if an element does not exist:
Selenium Test Case:
$this->type('id=search', $searchTerm);
Test Output:
RuntimeException: Invalid response while accessing the Selenium Server at 'http: //localhost:4444/selenium-server/driver/': ERROR: Element id=search not found
So, I get an error but I would like to convert it to a failure instead
I considered this:
try {
$this->type('id=search', $searchTerm);
} catch (RuntimeException $e) {
$this->fail($e->getMessage());
}
But I don't really want to convert all runtime exceptions to failures and don't see a clean way to distinguish them.
An additional assertion would be great but I can't find one that fits my need. Something like:
$this->assertLocatorExists('id=search'); // ???
$this->type('id=search', $searchTerm);
Am I missing something? Or is there another method that I did not think about?
Used versions:
- PHPUnit 3.7.14
- PHPUnit_Selenium 1.2.12
- Selenium Server 2.30.0