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.