EuroPython 2017

Front-end testing with Python

Speaker(s) Tim Babych

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.

in on Monday 10 July at 14:00 See schedule

Do you have some questions on this talk?

New comment