Selenium + Chromedriver gets stuck on Linux

4,401 views
Skip to first unread message

Mark Bramnik

unread,
Feb 3, 2016, 7:36:08 AM2/3/16
to Selenium Users
Hello,
Recently I've started to work with selenium grid and chromedriver. As an example I've started with 1 hub and one node which is configured to work with one browser only.
I use the latest available version of selenium (2.50.0) and version 2.21 of chromedriver

Here are the definitions of hub:

java -jar selenium-server-standalone-2.50.0.jar -debug -role hub


And Here are the definitions of node:

java -jar selenium-server-standalone-2.50.0.jar -debug -role node -hub http://localhost:4444/grid/register -port 5555 -browser browserName=chrome, maxInstances=1, maxSession=1 platform=Linux -Dwebdriver.chrome.driver=/tmp/selenium/chromedriver2_21/chromedriver

I'm running on Oracle jvm 1.8.0_72  on Linux Redhat 6.3 (64 bit) VM.

Now I run test client on my windows machine with the code like this:
...
public static void main(String[] args) throws MalformedURLException {
        for(int i = 0; i < 10000; i++) {
            System.out.print("[ " + new Date() + "] running test #: " + i);
            runSingleTest();            
        }
}

...
public static void runSingleTest() throws MalformedURLException  {
 ChromeOptions options = new ChromeOptions();
        options.addArguments(Arrays.asList("--window-size=800,600"));
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setPlatform(Platform.LINUX);
        capabilities.setBrowserName("chrome");      
        RemoteWebDriver driver = new RemoteWebDriver(new URL("http://<MY_HUB_HOST_GOES_HERE>:4444/wd/hub"),capabilities);
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
        driver.manage().window().setSize(new Dimension(800, 600));
        
        try {
            driver.get("http://www.google.com");
            // Find the text input element by its name
            WebElement element = driver.findElement(By.name("q"));

            // Enter something to search for
            element.sendKeys("Cheese!");

            // Now submit the form. WebDriver will find the form for us from the element
            element.submit();
           

        }catch(Throwable t) {
            // I just want to see it:
            System.err.println(t);
        }
        finally {
            driver.close();
        }

}


When I run it, I see that eventually (usually after 30-35 tests) chrome is not shown anymore on node machine and the test gets stuck. A this point there are 2 chrome processes at this point (not a renderer and no zygota processes). I don't see any kind of errrors/exceptions in logs of hub or node.

So, I conclude that sometimes chrome gets stuck unless I do something wrong in my setup.
But, maybe someone can point me on my mistake? What am I doing wrong?

Thanks in advance,
Mark

Krishnan Mahadevan

unread,
Feb 3, 2016, 7:48:26 AM2/3/16
to Selenium Users
Mark,
Can you please try replacing 

 driver.close()

with driver.quit() and see if that helps ?

driver,quit() when invoked basically sends a call to the server [ chromedriver is the server for chrome ] signalling it to shut down, which in turn closes off the chrome browsers.

Because you are invoking driver.close(), its basically just closing the browser, but perhaps the chromedriver binary is not getting flushed out from memory and maybe that's causing the problem.

Please give this a shot and let us know how it goes.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/9a07bd93-ff3f-49b6-8f13-e7ce9e90d0a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Bramnik

unread,
Feb 3, 2016, 8:28:18 AM2/3/16
to Selenium Users
Hi, Thanks for the reply Krishnan
I've checked your suggestion. This time it got stuck after 131 running.

I've run the ps -ef | grep chome when it got stuck:
And I attach here the output.
I don't understand whether it should be like this, but to me it sounds suspicious:
chrome process (4820) spawned by the chromedriver is in turn a parent process for  process 4876 which is also a chrome instance. 
In addition we have one process "<defunc>"



root@<MyUbuntuMachine>:~# ps -ef | grep chrome
root      4815 21056  0 15:18 pts/4    00:00:00 /tmp/selenium/chromedriver2_21/chromedriver --port=16002
root      4820  4815  0 15:18 pts/4    00:00:00 /opt/google/chrome/chrome --user-data-dir=/tmp/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.IMQQew/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12044 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.e6jn0E data:,
root      4833  4820  0 15:18 pts/4    00:00:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --user-data-dir=/tmp/.com.google.Chrome.e6jn0E
root      4834  4833  0 15:18 pts/4    00:00:00 /opt/google/chrome/nacl_helper
root      4837  4833  0 15:18 pts/4    00:00:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --user-data-dir=/tmp/.com.google.Chrome.e6jn0E
root      4875  4820  0 15:18 pts/4    00:00:00 [chrome] <defunct>
root      4876  4820  0 15:18 pts/4    00:00:00 /opt/google/chrome/chrome --user-data-dir=/tmp/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.IMQQew/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12044 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.e6jn0E data:,
root      5020  5001  0 15:23 pts/16   00:00:00 grep --color=auto chrome
root     21056 21055  3 15:09 pts/4    00:00:31 java -jar selenium-server-standalone-2.50.0.jar -debug -role node -hub http://localhost:4444/grid/register -port 5555 -browser browserName=chrome, maxInstances=1, maxSession=1 platform=Linux -Dwebdriver.chrome.driver=/tmp/selenium/chromedriver2_21/chromedriver

Thanks a lot in advance,
Mark

Jose María Sánchez de Ocaña

unread,
Aug 17, 2016, 7:15:28 AM8/17/16
to Selenium Users
Same thing happening to me. I run selenium v 2.53.0 together with chromedriver (Chromium 51.0.2704.79 Ubuntu 14.04) and my tests usually run without problem. Occasionally though, a chromium process will not end as expected and will indefinitely stay in a zombie state until I manually kill -9 it.

This is how selenium gets started in my /etc/init.d/selenium script:

su selenium -c "DISPLAY=localhost:99.0 java -jar /usr/lib/selenium/selenium-server-standalone.jar -port 4444 -trustAllSSLCertificates -timeout 300 -browserTimeout 300 > /var/log/selenium/output.log 2> /var/log/selenium/error.log & echo \$! > $PID_FILE"

I always close my chromium sessions by calling the quit() method of the selenium driver, which I also do whenever I capture a driver exception.

This did not happen with firefox, though, but I had to change over to chromium when some new firefox version broke the selenium compatibility of some feature I was using. Chromium is just working fine, but I have to periodically log in to my server and clean all the zombie processes...

Brine

unread,
Dec 11, 2016, 12:08:31 PM12/11/16
to Selenium Users
I have the same (or perhaps similar) issue. I'm running Protractor, headless via XVFB, on Ubuntu, and chrome would often hang on a test. I would see a "BrowserBlocking" process along with the hung chrome. I finally tracked down the solution... just add the following env var thusly:

export DBUS_SESSION_BUS_ADDRESS=/dev/null
Hope this helps
Reply all
Reply to author
Forward
0 new messages