Quality Testing

Quality is delighting customers

Throwing java.lang.NullPointerException while running Cucumber test cases with TestNG

feature file:

Feature: Google Search Functionality

Scenario: Search Cucumber information in google search
Given Navigate to Google Search
When Enter the search keyword in text field
And Click on Search button
Then Should able to see Cucumber information


package runner;package runner;
import org.testng.annotations.Test;
import cucumber.api.CucumberOptions;

import cucumber.api.testng.AbstractTestNGCucumberTests;

@CucumberOptions( features = {"C:\\Users\\eclipse-workspace\\practice\\src\\test\\java\\features\\googlesearch.feature"},  glue = {"stepdefination"})

@Testpublic class TestRunner extends AbstractTestNGCucumberTests {

StepDefination Code:

package stepdefination;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import cucumber.api.java.After;

import cucumber.api.java.Before;

import cucumber.api.java.en.Given;

import cucumber.api.java.en.Then;

import cucumber.api.java.en.When;

public class GSearch 


public static WebDriver driver;

@Before public void browser()


System.setProperty("webdriver.chrome.driver", "E:\\SeleniumLibs\\\\chromedriver_win32\\chromedriver.exe");

driver = new ChromeDriver(); driver.manage().window().maximize();


@After public void TearDown()




@Given("^Navigate to Google Search$")

public void navigate_to_Google_Search() throws Throwable {     driver.get("http://google.com");    

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

@When("^Enter the search keyword in text field$")

public void enter_the_search_keyword_in_text_field() throws Throwable {   driver.findElement(By.xpath(".//*[@id='lst-ib']")).click();  



@When("^Click on Search button$") public void click_on_Search_button() throws Throwable




@Then("^Should able to see Cucumber information$")

public void should_able_to_see_Cucumber_information() throws Throwable {     System.out.println("Cucumber information displayed");



Please find the attachment for exceptions.  

Views: 180


Reply to This

Replies to This Discussion

Can you please specify you pom.xml or versions of TestNG and Cucumber as well?


TTWT Magazine





© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service