0

I am getting NullPointerException for the above code. I am not able to understand where it is passing a null value.

Error:

java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.WebDriver.findElement(org.openqa.selenium.By)" because "this.driver" is null
 at com.example.PageObjects.DiscoverObjects.Splash_nextt(DiscoverObjects.java:60)
 at com.example.TestCases.Test.verify_open_application_land_on_disocver_tab(Test.java:37)
 at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Code: enter image description here

Shawn
  • 4,064
  • 2
  • 11
  • 23
Asad Atiq
  • 3
  • 4
  • It looks like `driver` is `null` when `new DiscoverObjects(driver)` is called. The initialization of `Test` (and of `ds`) happens before `setup()` is called. – Stephen C May 30 '23 at 13:54
  • Initialize `ds` in the `setup()` method ... AFTER you have created the driver and loaded the page whose objects you want to discover. – Stephen C May 31 '23 at 09:02

0 Answers0