Search code examples
seleniumcucumbercucumber-java

Null pointer while accessing webdriver from different Step definition class


I am trying to access launch static Webdriver instance in a different step definition class using a static method which has been defined in base class. While accessing it from different class it is giving nullpointer please help to solve this error

Here is my feature file Here is my Feature file

Here is my base class setup

Base class setup

Here is my Common step definition where method to invoke Webdriver instance is being called

enter image description here

Here is the second step definition classenter image description here

Here is the console logs

enter image description here


Solution

  • Line 20 in your stack trace suggests that read.getBrowserName() is returning null. Try swapping the arguments to equalsIgnoreCase()