Style: Procedural vs. Gherkin

Bryan Lamb
A free video tutorial from Bryan Lamb
My courses will improve your life and income!
4.4 instructor rating • 11 courses • 72,906 students

Learn more from the full course

Robot Framework Test Automation - Level 1 ( Selenium )

Fastest & easiest way to do Selenium test automation! Mobile test automation, API test automation, and database too.

06:27:57 of on-demand video • Updated April 2020

  • 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] In this video I'm going to briefly walk through two different styles of creating more readable scripts procedural versus Gerken. The subsequent videos you're about to see are going to walk through the procedural way of creating a readable script. But at the end of the unit I'll show you how you could also use lies GIRKINS and Dayaks to create a more readable script as well. Let's dig in. Here like I mentioned my test case is a series of domain specific keywords. So within the Amazon product I can search for things I can select products from search results I can add a product to cart and I can begin to check out those are things I can do in my Amazon business domain and it's pretty clear what this test case is going to do. If we instead look at the Gerken version of this test case you can see it reads very differently given a user is not logged in and user searches for products and the search results contains relevant products and the user selects a product from the search results and the correct product page loads and user adds the product to their cart and the product is present in the cart when the user attempts to check out. Then the user is required to sign in. So the test case is logged out user must sign in to check out. So you can see that are given in all of these ands are the preconditions that set up a test case. When is the actual test itself when the user attempts to click the checkout button and the expected result is the user is required to sign in. I can place my cursor in any keyword and hit Control V and it will take me to the resources file that holds that key word and you can see we're pretty much right back to the same pattern of calling methods on our page objects. So when a user searches for products we're going to load the landing page and then search for products on the top now. If we look at the test results for the style of test case you can see that we still have our set up and test hair down being triggered from the common keyboard file at the beginning in the end. But again you can see that this reads slightly differently than the procedural example we looked at before given user is not logged in and these are search of your products and so on and so on when these are attempts to check out then the user is required to sign in of course expanding any one of these keywords shows our page object methods in action and drilling into those ultimately again reveals the page objects are using Arslan into library keywords. Now something is a little bit quirky is that the name of our key word file is being prefixed to the beginning of each of the keywords so that makes this Gerken stuff a little bit less readable. I would prefer if that was there but that's just how robot framework works. And my point behind showing you all this is to drive the point home that your test results file is very important. And in my opinion you should design your scripts in keywords in a way that will make your test results most readable to the people who are going to be reading them. This is the procedural results. This is bigger than result's. So that was a quick tour through the final result. If you totally get it feel free to skip the rest of the videos and run off and do it yourself. But for those of you who are interested watched the next several videos and I'll go through and I'll break this process down step by step.