-3

Take a look in below code

newDriver.findElement(By.name("IDToken1")).sendKeys("2018713");

this statement is not working.. coding is fine. But still it fail to take data. Is there any problem on website? exception got,

Exception in thread "main" java.lang.NullPointerException

Please help me out

Raj
  • 11
  • 4
  • 4
    Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Filburt Oct 25 '17 at 06:01
  • Maybe you are searching by.name and the identification have a IDToken, is the name property correct? you should add more information, e.g. the html code. – j.barrio Oct 25 '17 at 07:04

1 Answers1

0

A quick solution would be to check the following:

  1. Check if newDriver is the only instance of WebDriver interface that exists within your program when this line of code is executed.
  2. Ensure that newDriver is not initialized locally within a method and simultaneously initialized globally within the Class scope.
  3. As you mentioned in your comment that you are accessing the same WebDriver instance i.e. newDriver you need to write a constructor in that class as :

    //declare the webDriver instance
    WebDriver driver;
    
    //constructor
    public method_name(WebDriver newDriver)
    {
        this.driver=newDriver;
    }
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352