Differences Between Selenium and Cucumber

SeleniumCucumberAutomation TestingTesting Tools

There are differences between Selenium and Cucumber are listed below −

Sr. No.SeleniumCucumber
1It is a test automation framework.It is not a test automation framework.
2Primarily used for automation testing of front end applications.Primarily used as a tool for behavior driven development.
3Can be written in any programming language like Java, Python, Ruby, C#, and so on.Can be written in Gherkin language.
4Developed in Java.Developed in Ruby.
5Can only be used by users having technical knowledge.Can be used by users without any technical knowledge.
6Less readable compared to Cucumber.Easily readable.
7Installation is lengthy and complex compared to Cucumber.Installation is easy.
8Conditional statements can be incorporated.Conditional statements cannot be incorporated.
9Syntax errors can be easily determined.Syntax errors often get unnoticed.
10All the project stakeholders (developers, testers, product owners, business analysts, clients and so on) can contribute.Team members- developers and testers can only contribute.
11Enables us to automate steps which are manually performed on the browser.Enables creating scenarios in plain English with the help of the keywords - Given, Then, When, and so on in the steps.
12Consists of only one file which contains the script implementation.Consists of three files – Feature file, Step Definition file (implementation of steps in Feature file) and Test Runner file.

Implementation with Cucumber −

Feature File

Feature: Login Module
Scenario: User login
Given: Visit URL "https://tutorialspoint.com"

The corresponding Step Definition File

@Given ("^Visit URL \"([^\"]*)\"$")
public void visit_url(String u){
   System.out.println("URL is : " + u);
}

Example

Implementation with Selenium −

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class BrwserLaunch{
   public static void main(String[] args) {
      //configure path of IEDriverServer.exe path
      System.setProperty("webdriver.ie.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\IEDriverServer.exe");
      //object of InternetExplorerDriver
      WebDriver driver = new InternetExplorerDriver();
      //URL launch
      driver.get("https://www.tutorialspoint.com/index.htm");
      driver.quit();
   }
}
raja
Published on 07-Apr-2021 09:08:31
Advertisements