Test setup using xvfb + PyCharm + vagrant

I have this environment:

  • PyCharm running on Mac OS X
  • Python3.4 environment running on a Ubuntu server in a stray instance

I want to be able to run / debug tests using PyCharm. While I can do this, but I recently added selenium for my tests, now I need to wrap the python interpreter in a remote xvfb-run command. I tried to add a remote external tool, but I cannot get it to work. I found this guy , but he doesn’t explain very well how he did it. Any idea would be greatly appreciated :-)

+1
python selenium pycharm xvfb
Mar 30 '15 at
source share
1 answer

Thanks to this answer , I decided without adding an external tool. Steps:

  • Installed xvfbwrapper in a python remote environment
  • Code example:

    from selenium.webdriver.firefox.webdriver import WebDriver from django.contrib.staticfiles.testing import StaticLiveServerTestCase from xvfbwrapper import Xvfb class UITestCase(StaticLiveServerTestCase): fixtures = ['data.json'] @classmethod def setUpClass(cls): cls.vdisplay = Xvfb() cls.vdisplay.start() cls.selenium = WebDriver() cls.selenium.implicitly_wait(3000) super(UITestCase, cls).setUpClass() @classmethod def tearDownClass(cls): cls.selenium.quit() cls.vdisplay.stop() super(UITestCase, cls).tearDownClass() def test_list(self): self.selenium.get('%s%s' % (self.live_server_url, '/#/app')) count = len(self.selenium.find_elements_by_xpath('//*[@id="data"]/tbody/tr')) self.assertEqual(count, 2) 
  • No changes needed for your test configuration (assuming it has already been completed successfully)
+3
Mar 30 '15 at 10:42
source share



All Articles