Getting error while calling the takescreenshot function in test | Selenium Forum
A
Avijeet Posted on 30/08/2019

1. Created for takescreenshot in baseclass as below.

 

//     #########################   Take Screenshot   ###############################################

                       public  void takeScreenShot(){

                          

                  File srcFile=((TakesScreenshot)cd).getScreenshotAs(OutputType.FILE);  

                                  FileUtils.copyFile(srcFile, new File("C://Selenium_Project//PPDS_CDM_Timeliness//screenshots//abc.png"));

                                                      }

                    

2. When trying to call the function in test.java its throwing null  pointer exception. where as if i'm putting this code inside my test script then its working fine.

 

Please advise.


A
Avijeet Replied on 30/08/2019

I have noticed 1 thing . for all the function which i have created in baseclass if i m calling the function in test.java then its showing null pointer error.

 

When m calling the function directly calling the function.

eg: if function name is takeScreenshot() then in test class tried calling by  takeScreenshot()  and this.takeScreenshot(). for both its showing null pointer error.

 

note i have extend the baseclass in test.java.


A
Ashish Thakur Replied on 31/08/2019

I would suggest you refer to the video carefully. We have discussed everything in detail there.