Tim Babych - Front-end testing with Python
Channel: EuroPython Conference
Date: 28/09/2017

"Front-end testing with Python
[EuroPython 2017 - Talk - 2017-07-10 - PyCharm Room]
[Rimini, Italy]

Web-developers use Python to develop web-applications, serving HTML or JSON content to user's browsers which render it. We test our applications to check that they serve content right and that they respond to HTTP requests in an expected way. However, this is not all that happens in a modern web application. There are lots of moving parts which are executed not on the server, but directly in user's browser, and they need to be tested too. The best way to check that our app works well in a browser is to test it in a browser, and Python gives you tools to do that conveniently.

With a Selenium tool and Python package, you can control the browsers, making them open web pages and interacting with them. I will show how to install Selenium and needed drivers, and tell about best practices for writing Selenium tests, such as


Page Object pattern
Put browser interactions in the page object, not the test
Put assertions in the test, not the page object
Never use time.sleep()
Always make pages wait for actions to complete
Wait for JavaScript to load


To test the visual look of your application there is a Needle tool, which lets you compare screenshots with baseline set, and highlight the differences. I will talk about how to incorporate that functionality into your tests.

As browser testing can get quite slow, I will also show how to set up running them concurrently.

License: This video is licensed under the CC BY-NC-SA 3.0 license: https://creativecommons.org/licenses/by-nc-sa/3.0/
Please see our speaker release agreement for details: https://ep2017.europython.eu/en/speaker-release-agreement/