This has been brought up before as well, but I don't think was ever resolved.
Sounds like a relatively easy fix... Contributions welcome!
According to the docs findElements() should return an empty array when no elements are found
It does. This method is just unsafe (missing @throws tag).
WebDriverCurlException signals some kinds of important problems. IMO there is no need to fix this method.
:+1:
I have the same issue.
How can I check if an element exist then ?
To answer my own question, the curl exception would happen only if there was an implicit wait.
driver->manage()->timeouts()->implicitlyWait(30);
once removed the implicit wait, findElements() would just return an empty array when no element was found.
I was in a similar situation and I did this with success in case someone is on the same boat.
1. Under my name space
use \Facebook\WebDriver\Exception\NoSuchElementException;
2. In my code
try
{
$search = $driver->findElement(WebDriverBy::xpath('//*[@id="content"]/p[1]'))->getText();
}
catch (NoSuchElementException $e)
{
// the element did not exist
var_dump($e);
}
@emilorol However you are using findElement() method here, which is supposed to throw NoSuchElementException in this case.
The original issue was about findElements() (note the s) method, which should always return an array - an empty one if no elements were found. However I cannot reproduce this original issue (findElements() throwing an exception instead of returning empty array), but if anyone can, an reproducible testcase or pull request is definitely welcome :)
Oh, my bad.
I visit this page looking for a solution on how to tell when the element is not present on the page so that the test will continue on one direction or another.
Thank you.
any one tell me which method decide that how many test case should be automate in selenium
Most helpful comment
I was in a similar situation and I did this with success in case someone is on the same boat.
1. Under my name space
2. In my code