Automated testing using Behat and Selenium

Do you want to deliver a well-tested website, covering all the test scenarios in every iteration? Excellent, then what is the problem? Oh, too much of manual effort in executing the regression test cases. Well, then automate it. Now, what? Automation, huh, it needs a lot of coding, too much of investment. OK, enough reasons given, the list can go on.

Get started right on with automating your test scenarios with minimal code is what all Behat is about. Behat proved to be extremely useful to me in order to enter the world of automation. After understanding the architecture and its correct usage, my team and me could automate around 70% of the test cases by writing no/minimal PHP code. The lovely features provided by Selenium Webdriver can be easily integrated into Behat with the help of Selenium2Driver which comes out of the box. It is an automation testing framework, coupled with rich libraries in the form of extensions to enable users automate their acceptance tests, API tests and even create a Page Object model when needed. You can execute tests on various browsers or even headless browsers like phantomJS and headless Chrome for faster execution.

Since Behat is built on the lines of Cucumber and promotes BDD, it has proved to be an extremely useful tool to ensure that were are first building the right system followed by the system is being built right. With the help of human readable scenarios written in the feature files, the automation system can be understood by all the three parties - Business people, developers and testers. Gherkin language enables the tester to build more and more strong and a rich Automation test suite than trying to get the code right. composer.json and behat.yml files enable the user to configure stuff in no time.

 
4 favorite thumb_down thumb_up 2 comments visibility_off  Remove from Watchlist visibility  Add to Watchlist
 

Outline/Structure of the Workshop

  • Introduction to BDD

    1. How it works in real life?

    2. Why is it used?

  • Introduction to Behat

    1. What is Behat?

    2. Initialize a Behat project

      1. Explain composer.json and composer.lock in brief

      2. Explain composer install and composer update in brief

    3. Architecture of Behat

  • Introduction to Gherkin

    1. Hello Gherkin

      1. Background

      2. Scenario

      3. Scenario Outline

      4. Gherkin keywords

    2. Write your first feature file

    3. Let’s try execution together

  • Introduction to Mink : web app testing

    1. What is Mink?

    2. Installing Mink

    3. Let’s update the composer together

      1. Add dependencies in composer.json

      2. Update the composer

    4. Configuring Mink

      1. Activate the extension in behat.yml

      2. Configure goutte and Selenium2 drivers

    5. Let’s extend Mink in the current context

      1. Modify the FeatureContext file to point to the right context

    6. Ready to use steps in Mink

      1. Interact with all types of web elements

    7. Let’s try executing it together!

      1. Run tests using Goutte

      2. Browser based execution

      3. Execute tests using Headless Chrome

    8. Enhance your tests

      1. Add custom step definitions by minimal PHP coding

    9. Other extensions in Behat

      1. List few widely used extensions in behat

      2. Four golden steps to get started with any extension

      3. Reporting extension to generate readable test reports

      4. Screenshot extension to capture screenshots of failed scenarios

      5. Learn how to execute the scenarios on multiple environments or browsers using profiling

Learning Outcome

Come and learn on how to kick start your Automation career and get started with Automation using Behat and Selenium - BDD way.

Target Audience

QA Engineer, Test Engineer, Technical Project Manager, Automation Engineer

Prerequisites for Attendees

  1. Setup MAMP (Mac) / LAMP (linux) / XAMPP (Windows) (Apache, MySQL and PHP)

  2. System wide installation of Composer

  3. Any IDE of your choice. (PHPStorm preferred - which comes with a trial version for 30 days)

Please pre-configure your machines with the above.

schedule Submitted 1 year ago

Public Feedback

comment Suggest improvements to the Speaker
  • Anand Bagmar
    By Anand Bagmar  ~  1 year ago
    reply Reply

    Hi Shweta, Mohit,

    Though you have submitted this as a full day workshop, just wanted to check with you the feasibility of doing this as a 45 min session - as getting started with Behat - and as 1st step in that session - why would one use Behat instead of Cucumber? If you think that is feasible, could you submit another 45-min session with the relevant details? That gives the program team more options to balance out the program.


    • Liked Simon Stewart
      keyboard_arrow_down

      Simon Stewart - Fix a Bug, Become a Committer

      Simon Stewart
      Simon Stewart
      WebDriver Creator
      Facebook
      schedule 1 year ago
      Sold Out!
      480 Mins
      Workshop
      Beginner

      Have you ever wondered how Selenium works under the covers? Do you get frustrated with locators not locating, pages not loading, or browsers behaving inconsistently from one run to the next? Selenium is an attempt to unify thousands of disparate elements across a wide spectrum of challenges into a single, common interface that works seamlessly with all the major browsers - and yet only a handful of volunteers work to maintain this gigantic effort. If you would like to enhance your own Selenium experience while contributing back to the software that has defined so many of our careers, come to this workshop. In it we'll dissect the different elements of Selenium, dive into its internals, learn how it was built and how to make changes to it, and even write a unit test you can contribute on the same day!

    • Liked Manoj Chiruvella
      keyboard_arrow_down

      Manoj Chiruvella - Smart Test Failure Analysis with ELK (Elastic Search, Log Stash & Kibana)

      Manoj Chiruvella
      Manoj Chiruvella
      Principal QA Analyst
      Oracle
      schedule 1 year ago
      Sold Out!
      20 Mins
      Talk
      Advanced

      In contemporary test automation world, we are running 1000's tests every day. Even though most of our test cases are reliable and stable, debugging failures will consume lot of time, if not handled appropriately. This is an effort to reduce the analysis of failures and come up with probable root cause for each and every failure.

      In this talk, we will explore all the approaches we have taken to drastically reduce the time to debug the failures & let you concentrate more on adding new tests. We will also talk about the approaches which could not yield results for us initially & why. We will look into building a failures' dashboard, driven by pattern based classification of logs(both server & automation tool) with reporting.

    • Liked Shweta Sharma
      keyboard_arrow_down

      Shweta Sharma - Welcome to the world of Automated Visual regression testing

      45 Mins
      Talk
      Beginner

      I want the site to be tested on Firefox, Chrome, Safari and yes, even IE 11. To add, the site should be responsive and should support mobile and tablet resolutions too. How often do you see this being listed in a Test plan? Almost, all the websites need to supported on multiple browsers and devices, right? Just imagine the manual effort required here. To add, the site is multi-linguistic. Wow, that just doubled all your manual efforts! How about if we automated the visual regression tests too, just the way functional regression tests are? Sounds great, isn't it?

      Once you agree with the above paragraph, allow me to explain the concept of automated Visual regression testing, how the visual tools work in general, the concepts around it and the benefits of using them, along with the challenges faced during actual implementation of the tests. There are a couple of tools available in the market, using which you can directly get started with automating your visual tests too.

      Even if you have a large QA team, identifying CSS issues on multiple browsers and devices with every build can become a tedious job, erroneous since once cannot capture small pixel differences or even similar color related issues. Therefore, automating them is soon going to be a must have in every Test Plan.

    • Liked Shweta Sharma
      keyboard_arrow_down

      Shweta Sharma / Mohit Aghera - Behat - Arguably the best PHP tool to switch to Automated testing from Manual

      45 Mins
      Talk
      Beginner

      In no time, the term 'Manual QA" is going to be a dinosaur. What does that mean? Are all the Manual QA going to extinct? Thank Behat, Manual testers can have a bright career into Automation. The term automation is itself horrifying, which means complex framework, complex setup and the biggest of all, lots and lots of coding involved.

      Behat is an open source BDD PHP framework. It has a rich library of extensions which will help you test user workflow and interact with the Web application using Mink, test your APIs and also develop a Page Object Automation framework.

    • Liked Syam Sasi
      keyboard_arrow_down

      Syam Sasi / Jerry Zhao - How to build a device lab in your office in 48 hours!

      45 Mins
      Talk
      Intermediate

      Continuous testing is an integral part of continuous delivery pipeline. When it comes to mobile application, the testing become increasingly complex.

      As part of our internal quarter hackathon at Carousell, we developed an automation testing framework and device lab in 48 hours which has both parallel and distributed mode of running.

      We will share about how you can set up a similar device lab in your organization and the best practices to be followed.

    • Liked Shivaling Sannalli
      keyboard_arrow_down

      Shivaling Sannalli - Unify service and UI layer Automation - BDD way

      90 Mins
      Workshop
      Intermediate

      Software delivery is switching towards business driven development. This needs capturing requirements as presented by clients and translating these requirements into development tasks and tests.

      Clients want visibility on the quality of the requirements that are captured. Quality in the delivery of the project measured using the test pyramid — heavy unit tests, more integration and service layer tests, and fewer UI tests. Test pyramid is the ideal quality structure for Agile projects.

      In this presentation/session we will focus on how we can combine both service layer tests and UI layer tests in a BDD(Behavior Driven Development) way of Automation. That will bring test coverage visibility to business. Clients themselves can run this suite without having to understand technicalities of the implementation. Test scenarios will exactly be the requirements captured by business as behaviors.

      To accomplish BDD way of automation for both service layer automation and UI layer we will use following tools/libraries:

      BDD Tool: Gauge or Cucumber (both are open source)

      Service layer Automation : Unirest for JAVA

      UI layer Automation : Selenium WebDriver for JAVA

    • Liked Siddharth Kulkarni
      keyboard_arrow_down

      Siddharth Kulkarni - Dr Culture Shock - Or How I stopped worrying and embraced Org Culture

      45 Mins
      Talk
      Intermediate

      The org culture mantra is usually considered a silicon valley mumbo jumbo. Although many companies and teams rant about culture, very few in my opinion take it seriously. In this talk I would like to discuss the importance of Org culture and how it makes or breaks businesses and teams. I will lay out some key pointers that will help the influencers in the audience make decisions about their org or team culture. The talk will be in the context of culture in tech companies.

    • Liked Gil Tayar
      keyboard_arrow_down

      Gil Tayar - Frontend Testing: Stepping in and Collaborating with Developers

      Gil Tayar
      Gil Tayar
      Sr. Architect
      Applitools
      schedule 1 year ago
      Sold Out!
      45 Mins
      Talk
      Intermediate

      Testing is shifting left, moving closer to testing the code itself, and not the full product. But while managers dictate a shift to the left, the developers and testers themselves are confused as to how exactly to test the code. While the backend world already has established methodologies for testing, frontend developers and testers are still trying to figure out how to test their code.

      Testers need to step in and work with the frontend developers. Testers need to understand the framework by which frontend code is tested. They need to understand the various kinds of testing that can be performed on frontend code, and which tools can be used for this.

      I will give a recipe that you can follow to ease your fear of the unknown —writing tests for developer code. I will discuss the various kinds of testing and how they fit together in a coherent way, but most importantly - I will include sample code that you can use as a template in your own project, and if time permits—a bit of live coding will be done.