Selenium hangs indefinitely on starting chrome with chromedriver and Xvfb

1,353 views
Skip to first unread message

Trevor Haba

unread,
Feb 17, 2015, 5:31:14 PM2/17/15
to seleniu...@googlegroups.com
I am creating an app that continuously opens a page in chrome and then takes a screenshot. It does this once every 30 seconds. It is running on EC2 with an Xvfb instance using xvfbwrapper: (https://github.com/cgoldberg/xvfbwrapper). The program works fine when running on my personal computer, and it works fine at first when running on EC2. However, when it is left to run for several hours, it eventually ends up hanging indefinitely. Here is the relevant pieces of code:

I am using: ChromeDriver 2.14.313457
Google Chrome 40.0.2214.111
Selenium 2.42.1

While true:
    xvfb = Xvfb(width=1920, height=1920)
    xvfb.xvfb_cmd.append('-noreset')
    log("starting Xvfb: " , xvfb.xvfb_cmd)
    xvfb.start()

    try:
        options = Options()        
        options.add_argument("--disable-web-security")
        options.add_argument("--webdriver-logfile=webdrive.log")
        dc = DesiredCapabilities.CHROME
        dc['loggingPrefs'] = {'browser': 'ALL'}
        log("preferences set, attempting to start driver")
        driver = webdriver.Chrome(chrome_options=options, desired_capabilities=dc)
        log("driver started, attempting to load page")
        driver.get(url);
                 log('loaded the page')
        data = driver.get_screenshot_as_base64()      
        driver.quit()
        xvfb.stop()

From the log files, I see up until `preferences set, attempting to start driver` and then nothing, for many hours, until I manually restart the program. Then it starts working fine again. It appears that the call to `webdriver.Chrome(...)` never returns, and never throws an error either. The program is just indefinitely waiting. 

I have looked for out of memory exceptions following the post here: https://unix.stackexchange.com/questions/128642/debug-out-of-memory-with-var-log-messages and nothing presents itself. 

How can I continue to debug this? Is there a way to see more detailed log messages from selenium? Or from chromedriver? 

Krishnan Mahadevan

unread,
Feb 18, 2015, 12:48:54 AM2/18/15
to Selenium Users
Trevor,

When you say it works fine on your local computer, do you mean that you left it running for the same amount of hours as you did with the EC2 cloud ?

Looks like you are running this on an endless loop.
Should you be moving the instantiation part outside of the loop ?

 xvfb = Xvfb(width=1920, height=1920)

because this is going to be creating an object for every iteration. I dont know how the garbage collection works for you in your programming language [ pardon me.. I know only Java. So I wasnt able to figure out what language is it ].



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/a7adba54-1a42-4577-ae01-540b29b6a9d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Trevor Haba

unread,
Feb 18, 2015, 5:34:16 PM2/18/15
to seleniu...@googlegroups.com
Krishnan,

I'm using Python which should be managing that memory for me. Either way, I have tried the situation both ways, where I create a new Xvfb instance on each run, or using the same long running instance, and both ways lead to the same behavior.

Tongda Zhang

unread,
Mar 14, 2017, 12:35:10 PM3/14/17
to Selenium Users, trevo...@paperg.com
Hi Trevor,

Have you solved this problem by any chance? I encountered the similar problem using EC2.

Thanks.
Reply all
Reply to author
Forward
0 new messages