lundi 9 février 2015

How to start Flask dev server from within Selenium tests?

I'm building a website using the (excellent) Flask framework and I'm now writing UI-tests with Selenium. In the setUp method of the tests I'm rebuilding the (sqlite) database from scratch so that I have a clean DB to test with. Because I'm still developing it's not a problem that I'm constantly losing the contents of my DB, but in the future this will of course become a problem.


So to try to avoid this, in my Selenium tests I first change the name of the DB in my config.py file, after which I rebuild the DB (or I'm actually creating a new test-DB). The problem is that the running instance of the dev server doesn't run from that database. So as far as I now understand, I not only need to be able to create a new test-DB from within the Selenium tests, I also need to run the dev server from within Selenium so that I can run the website on the newly created test-DB.


So my question: how do I start the Flask dev-server from within Selenium so that it can use the newly created test-DB? Or are there even different solutions?


All tips are welcome!


1 commentaire: