When running synthetic browser tests using Selenium and Google Chrome, we intermittently receive a Selenium error (see below) on a particular website. The flow is:
The error occurs during the click action (step 4), but the final screenshot (step 5) contradicts this and shows the search to have been initiated (only possible via a click - some form of auto search is not implemented on the website) and returned results.
Error:
Curl error thrown for http POST to /session/a4ec9662-1841-4809-9680-caf532b243b7/element/2/click
Operation timed out after 30001 milliseconds with 0 bytes received
Stack:
selenium/standalone-chrome:3.0.1-germanium
I have found another post regarding this that suggested to set this environment variable to the docker container: DBUS_SESSION_BUS_ADDRESS=/dev/null
, however, this has not worked.
How we manage the container from code:
$Docker = new Docker();
$Manager = $Docker->getContainerManager();
$Container = $Manager->find($container_name);
if ($Container) {
if ($Container->getState()->getRunning()) {
// Restart container based on some logic around runtime and usage
} else {
$Manager->start($Container->getId());
}
}
How we handle 'click' actions:
$Element = $this->WebDriverSession->findElement(By::cssSelector($css_selector));
if ($Element->isDisplayed()) {
$Element->click();
}
EDIT:
I've upgraded our Selenium container to 3.4.0-einsteinium
and am still seeing issues.
We have always had issues with some target websites not loading first time and Selenium throwing this error...
Curl error thrown for http POST to /session/cd18695c-bf88-482f-998e-4d8039c22359/url
...we get around this by catching that error and retrying x times before giving up. This update hasn't fixed this either.
To verify, if the element can be clicked, we shall use the elementToBeClickable condition. A timeout exception is thrown if the criteria for the element is not satisfied till the driver wait time.
Selenium clicks fail when an element is not attached to the current page. Re-find the element if the previously found element has been detached.
Alternative of click() in Selenium We can use the JavaScript Executor to perform a click action. Selenium can execute JavaScript commands with the help of the executeScript method. The parameters – arguments[0]. click() and locator of the element on which the click is to be performed are passed to this method.
The same kind of error is reported in docker-selenium
issue 163, and seems related to selenium alone.
That is why there now (Aug. 2017) is SeleniumHQ/selenium
issue 4384 (now Oct. 2017 closed, as a "performance issue").
That error was also seen in docker-selenium issue 20 (2015) with this comment, more about Chrome crashing:
Started in privileged mode:
docker run --privileged
Fix small /dev/shm size
docker exec $id sudo umount /dev/shm docker exec $id sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
Update End 2017: issue 163 mentions
Maybe there is a bug in supervisord, you can try to bump the version or even go back to an older one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With