Robot Framework vs. Selenium

A free video tutorial from Bryan Lamb
My courses will improve your life and income!
Rating: 4.5 out of 5Instructor rating
13 courses
150,069 students
Robot Framework vs. Selenium

Lecture description

Robot Framework makes Selenium automation EASY!

Learn more from the full course

Robot Framework Test Automation - Level 1 ( Selenium )

Robot Framework 5.0 is the fastest & easiest way to do Selenium, API, and database test automation!

08:20:02 of on-demand video • Updated September 2023

Install & configure the Robot Framework test automation tool plus libraries like Selenium, API, database, and more
Create & run your first Robot Framework test automation script (Selenium Webdriver example)
Understand the basics of many Robot Framework test automation libraries (Selenium Webdriver, API, Database, XML, Files, etc.)
Use the page object pattern to create more reusable, easier to interpret test automation scripts
Run/execute Robot Framework automated tests in many different ways, including from a command window, batch files, Jenkins, and Windows task scheduler
Create user defined keywords to express your tests in business domain terms instead of cryptic Selenium Webdriver code
English [Auto]
The question that comes up a lot when I talk about robot framework is why should I use robot framework versus selenium? Well, that's not really a valid question because robot framework, in a sense is selenium because it's an abstraction layer or a wrapper on top of selenium. You can see here that I have this script robot file at the top and it is capable of interacting with any of these libraries shown below. So if you decide your script wants to do selenium testing, you simply load up that Selenium library that's highlighted in yellow and start writing simple keywords to create your script. So let's see a specific example of this. This is a typical Selenium test, and you can see up at the top, I've added a bunch of using statements that bring features into the file we're trying to work with. Then we've got a namespace, we've got a class, and we've got a main function and a bunch of C-sharp code here where we're doing up variables and using C-sharp syntax to spin up a new Firefox web driver. And we're going to navigate it to Bing. We're going to maximize the window, we're going to identify an input field and type in some keys, and then we're going to hit the enter key to submit that search and finally close the window. Now, what's interesting is in order to use different browsers, you'd have to bring in a different using statement for different Web drivers. And then in the test, you have to specify somehow which Web driver you want to use in some kind of a switch statement. So you can see that for a person who doesn't have any existing programming skills, this is pretty steep learning curve. By contrast, this is what a robot framework web test looks like. I have one line at the top that says, I want to bring in the Selenium Library. Then I create the name of my test case. There's no classes or namespace or anything like that, just the name of the test case. And then at the beginning of each of these lines is a selenium keyword. So I can say open the browser and I can pass in two different pieces of information to that. I could say wait until page contains and pass in what I'm waiting for. Then use input, text and pass in the locator and what I want to input. Then click a button and pass in the locator to click that button and then sleep here. I just have that to keep the window open so you can see it and then finally close browser. So at its simplest, you can see that robot framework is a very easy, keyword driven language to use. Taking it a step further, you can see one more formal example. In this example, I'm comparing it to Cucumber, which uses the Gherkin syntax. So you can see we have a little bit more up top here, including my documentation. I'm adding into resources that these test cases depend on. I've got tests set up and tear down and then each of my test cases and you can see here I'm using the Gherkin syntax given user is not logged in. When the user searches for products, then search results contains relevant products. So hopefully you can see here that by using robot framework, you can produce very easy to read test cases very easily and you can test a wide variety of things instead of just web like Selenium does.