![]() The first thing you need to do to switch to Chrome is to install Chrome if you don't have it yet (obviously!), and then you need to install ChromeDriver, which is the little bit of glue that allows Selenium to send commands to Chrome and automate it. This can happen if, for example, you did not have Firefox installed. The setUp() method checks that a client instance exists, and if it doesn't, it tells the unit testing framework that the test needs to be skipped. The tearDownClass() just destroys all the resources created in setUpClass(). ![]() You can't use the Flask test client for this type of test because the browser controlled by Selenium needs a real server it can connect to. Then a real Flask server is started in a background thread. ![]() The setUpClass() method creates a Selenium client, which is stored in the client class variable, and also creates an application context and a database. Self.skipTest('Web browser not available') # give the server a second to ensure it is tearDownClass(cls): # create the database and populate with some fake data # skip these tests if the browser could not be started In case you haven't seen my book, the way I configure the tests that use Selenium within Python's unittest framework is shown below: from selenium import webdriverĬlass SeleniumTestCase(unittest.TestCase): This super short article describes what you need to do to set up Selenium to use the Headless Chrome browser. I thought this was a great opportunity to see how Headless Chrome works, as that eliminates the annoying browser window that pops out every time you run the tests. In the current version of the book I recommend running these tests against Firefox. While working on the second edition of my flask book, I was reviewing my Selenium tests, which allow me to automate a web browser and do end-to-end testing.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |