0

I have a selenium code written in java. In this code i will give the @Before Test method to login to the website, later i have the excel sheet to continue the transactions. so now i can login to the website successfully. i have read the excel inputs and saved in the array list. now when i try to apply actions on the inputs, i am getting null pointer exception. Is that because the focus on the webpage is lost or is there any other reason? Please let me know the reason for the null pointer exception.?

case "id" :  
  System.out.println(this.driver); 
   webElement = this.driver.findElement(By.id(attributeValue)); 
break; 
lloyd
  • 1,683
  • 2
  • 19
  • 23
ChipChamp
  • 21
  • 1
  • 9
  • 1
    [A Null pointer exception and how to fix](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it). – lloyd Nov 30 '15 at 21:45
  • @lloyd. thanks for the link to previously answered question. I tried to trace back. I have the code like this - > case "id" : System.out.println(this.driver); webElement = this.driver.findElement(By.id(attributeValue)); break; when I try to print the attribute value. It is getting the correct value. when I try to print the driver value I am getting a null. I guess this is the reason for the null pointer exeption. how can I correct it? – ChipChamp Nov 30 '15 at 23:00
  • see my edit, how is your driver set? – lloyd Nov 30 '15 at 23:11
  • @Lloyd. thank you for the response. I was able to find the mistake. now it is resolved. the driver was not passed to the swtich. Now I have passed the driver to method and now working fine.. Thanks a lot for the help – ChipChamp Dec 01 '15 at 19:17

0 Answers0