Exploit the flexibility of Selenium WebDriver such as many programming languages, different browsers, OS, and so on; test repeat and iteration, W3C draft, Java, JUnit, and Maven.
- [Instructor] Welcome to the third section of this video course, Selenium WebDriver. We will look at WebDriver in this section. WebDriver is a library that will allow us to control a browser from a programming language, such as Java, C Sharp, Ruby, Python, Perl, PHP, and much more. Python, Perl, and PHP, I have abbreviated as 3P. Instead of controlling the browser from a Firefox plugin as we did in the previous section, you will now be able to do the same thing using your favorite programming language.
Let's begin our journey to understand WebDriver. In this video, we shall look at a few programming languages and some tools of WebDriver. So what is WebDriver? And what is the problem WebDriver helps us to solve? WebDriver enables one to automate the testing of your web application and to find any regressions before one deploys a new version of your application.
WebDriver will allow you to automate the testing of your web application using various browsers, such as Safari, Chrome, Internet Explorer, and Opera as well as Firefox. This will save you a ton of your time. Why would you want to use a programming language? There are many reasons for this. Flexibility, a general purpose of using a programming language is its flexibility. You can do almost anything with it, at least anything you can do with a computer or device.
Selenium IDE will only allow you to use Firefox, whereas WebDriver will enable you to use any browser. Automation, the idea here is to create tests with your programming language for small operations. These small tests can be used to automate small things. These small things can then be combined into larger chunks, and after a while, you may end up with a completely automated test suite of your web application.
Automatic testing with the help of WebDriver can be done in many environments, such as various OS and browsers. It can be run in CI by scheduling. In the previous section, we discussed that Selenium IDE was a place to start but not a place to stop. WebDriver is the place to continue after Selenium IDE. WebDriver is the result of merging two competing projects that solved the same problem, the control of a web browser remotely.
This means that you will most likely be able to use your favorite language to automate your testing. I prefer using Java, so I'll use it in this course. If you haven't installed Java on your computer, now is a good time to install Java. After the installation, set the correct path for Java. Go to oracle.com. Download and install Java JDK. Make sure that it is the JDK and not JRE, Java Runtime Environment.
When you are done, open up a terminal or command line window. Type and execute the following command to verify the Java installation, java -version. It should tell you about the Java version. If it doesn't work, check your path and ensure that it's working. You will not be able to follow the examples hereon without a working Java installation. It is also important that you are able to compile a Java program. Verify it by running one, javac -version.
This will tell you your Java's compiler version. Let me set my path correctly, and you can follow if you haven't already. Go to Properties, Advanced system settings. Go to the Environments Variable tab. Set the path value, C:\Program Files\Java\jdk1.8.0_05\bin in user variables.
Set the class path value as .;C:\Program Files\Java\jdk1.8.0_05 in system variables. And let's set JAVA_HOME value as C:\Program Files\Java\jdk1.8.0_05 at system variables.
We have now set the path for Java and Java -version, and Javac -version should work well. Most of the examples will be implemented using JUnit, but they can obviously be implemented in a main or any other testing framework, such as TestNG. We will add JUnit as a dependency to the project we create. We will also use Maven as our build tool. This will enable us to simplify the dependency handling and create small examples that are easy to implement on your own without creating or handling too much infrastructure.
Some people are not comfortable with Maven. If so, feel free to use something else that solves your problems better. Gradle could be a great candidate. However, we will use Maven and suggest that you do the same. If you haven't installed Maven yet, now is a good time to do it. Go to maven.apache.org. Download and install it. After the installation, do verify the installation via the command line.
Maven is installed on my machine, and the class path is already set up. Let's go to our terminal and type and verify it. Type mvn -version. So we're using Maven version 3.3.3. You can also verify the version using the command mvn --version. Now that we have installed Maven successfully, let's set up the Maven path.
Right click on My Computer. Go to Properties, Advanced system settings, Environment Variables. Please set your Maven path as shown. The folder should be set as apache-maven-3.3.3 with variable name as M2_HOME. Also, set the path as %M2_Home%\bin at user variable.
So this is how we set up Maven class path and Maven home after installation. I hope you have noticed that we have preferred using the command line in some situations. The simple reason for this is the fact that using command line tools enables us to automate a lot of the things we do. We can write small scripts for common tasks. Later on, it also allows us to integrate these tools in a continuous integration server. WebDriver for Java is updated frequently.
It seems to be updated about once a month and has been updated this often for the last three years. In this video, we have installed Maven, verified it, and set its class path. Join me in the next video so that we can actually go through some implementation. See you there.
Selenium gives developers the power to control web browsers and use them to automate web application testing. As an open-source toolset, Selenium makes it easier for testers to evaluate web applications without putting in any extra time and effort.
Mastering Selenium Testing Tools is all about demystifying the Selenium suite. Learn to verify web applications, control browsers with code, and scale up the testing environment by distributing the execution of web applications on different browsers running on different operating systems.
Author Ripon Al Wasim starts with the Selenium IDE, a Firefox plugin that performs a simple record-and-playback of interactions with the browser. A tester aiming for professional output can use WebDriver, an advanced scripting tool that allows you to locate the elements you need to interact with using their name: id, xPath, or CSS. Next, learn to express the desired behavior using a well-known framework for behavior-driven development (BDD) called Cucumber for Java, which uses a language called Gherkin. Last but not least, Ripon shows how to run tests on the Selenium Server, and walks through a complete working example of Selenium and Cucumber in action, for acceptance testing of a web application.
- Preparing your Selenium test environment
- Using the Selenium IDE
- Scripting in WebDriver
- Locating web elements
- Writing test cases with the Page Object Model
- Enabling continuous delivery with a continuous integration build system
- Working with Cucumber and Gherkin
- Describing features with Cucumber
- Running tests on Selenium Server