2

I have been playing around with python and selenium - and I am able to do successful testing using selenium. To avoid showing the browser, I started using Xvfb and then the script fails. So, at first, my normal code looks like so:

self.driver.get(url)
time.sleep(2)
/* do some stuff */
driver.close()
driver.quit()

Now I simple replace the above using:

vdisplay = Xvfb()
vdisplay.start()
self.driver.get(url)
time.sleep(2)
/* do some stuff */
driver.close()
driver.quit()
vdisplay.stop()

.. however, I seem to get a NoSuchElementException (I found this by wrapping the above code in a try-catch statement) as follows:

Message: u'Unable to locate element: {"method":"id","selector":"element-name-profile"}' ; Stacktrace: 
at FirefoxDriver.prototype.findElementInternal_ (file:///tmp/tmpfFvvOZ/extensions/fxdriver@googlecode.com/components/driver_component.js:9470)
at fxdriver.Timer.prototype.setTimeout/<.notify (file:///tmp/tmpfFvvOZ/extensions/fxdriver@googlecode.com/components/driver_component.js:407)

If I do not use Xvfb everything seems fine. I have tried googling the problem - but could not find anything useful - was wondering if anyone in SO had encountered this.

JohnJ
  • 6,736
  • 13
  • 49
  • 82
  • I've never encountered with such problems, but try to use another headless browser e.g. PhantomJs http://phantomjs.org/download.html – Andrey Egorov Aug 30 '14 at 02:13

0 Answers0