Selenium is a popular python test automation framework for automating web-based application testing. In this tutorial, Xander briefly explains how to get started with Selenium and Django. He Starts a new Django project then Setup Django-Selenium. Here in this video, he takes a look at some very simple examples and covered topics like setting up the WebDriver, execute a simple test, and testing forms.
What is Selenium?
At 1:03, Xander answers this basic question, Selenium is an automated browser that provides us tools to perform actions automatically. On the selenium website, three basic tools are available:
- Selenium WebDriver
- Selenium IDE
- Selenium gold
Here in this video tutorial Xander discuss to effectively run and utilize selenium WebDriver
What is selenium WebDriver?
At 2:45, Xander tells Selenium now allow us to automate web-based application testing, a tool for a more comprehensive level of testing for our application which allows us to test application with multiple browsers and screen resolutions.
In this tutorial, Xander assumes that listeners are new to selenium and have basic Django knowledge of how to create a new project, etc. The starting code for this tutorial is given in the video description from where it can be downloaded.
After downloading and installing all the required files whose links are given in the video description and running them in visual studio, at 5:18, he explains pi test selenium package and a Django selenium package with a help of a basic example of a project called core that is set up with some URLs and contains some templates index, and extend all the files to base to test rendered HTML and the behavior of webpages.
Live server test case
At 8:11, Xander explains a tool code Live server test case which is basically the same as a transaction test case but it also launches a live Django server in the background and when the test is finished, shut it down automatically.
Here we can see the tool called live server test case which takes us down to the documentations here in Django and explains a little bit more about live server test cases. So the key point here is that when we utilize selenium it’s going to open up or it can open up a browser window and then it’s going to perform the same type of actions that we would do to test our application.
At 9:30, starts creating a new test to import live server test case. To send an instruction to the browser code must be translated into the actions and allow selenium to perform those actions in the browser, so here is the need for a selenium web driver in the test.
Setting path to the browser and practical examples
At 13:03, Xander set path to chrome web in order to click and run it easily. the chrome web driver which is right there in my folder as shown, Xander added it or pasted it there into my project and add the chrome driver to the windows path so anytime any person calls it, windows is going to look for that path for this particular file and run it.
At 15:24, Xander makes a simple test by utilizing the asset, “hello, world!”, and goes to website inspect, in order to make sure that testing is correct. This very simple test gives the flavor that how it is running. At 17:00, he added, it will be more simple and convenient who are familiar with unit testing.
At 18:30, Xander explains how utilizing time allows us to delay any actions that we want to perform and make sure that that action is complete before we run a different action or test. He performs this by setting time 5 seconds as an example and in the result, the window opens for 5 seconds and the test or the assert will then complete,
At 19:35, he builds a test to automate the process of navigating to a page by adding admin credentials and selecting form elements, “username and password” and inspect. Now with selenium one can select these inputs in many different ways. Xander guide about the different options to find the elements on the page, for example, common ones are CSS selector, by class name, by id, or a name which he showed and demonstrated here.
At 23:21, Xander shows and a little talk about other ways of locating documents which he said will cover by in later coming tutorials. He also shows the keyboard interaction on the page as well as the mouse and select things by giving example.
At 27:05. Xander goes to look in the page source and look for the word admin that should be in there because he logged in as admin and it should say or be printed on the page as user admin. He added here, one can slim it down and can define a little bit more if we wanted to in this specific example.
At 28:18 concluded the introduction about selenium with python Django. In this tutorial, he covers the basics to get started testing forms in the Django web application, which is the most generic thing in most applications.