Error while running with grid | Selenium Forum
M
Posted on 31/07/2016
hello,

trying to run the test cases by Grid for module 21 framework. however i am getting following error. please help....

java.lang.NullPointerException
at com.qtpselenium.framework.util.Keywords.takeScreenshot(Keywords.java:
514)
at com.qtpselenium.framework.util.Keywords.reportError(Keywords.java:546
)
at com.qtpselenium.framework.util.Keywords.openBrowser(Keywords.java:202
)
at com.qtpselenium.framework.util.Keywords.executeKeywords(Keywords.java
:79)
at com.qtpselenium.framework.SuiteB.AddPortFolioNewStockTest.deleteStock
(AddPortFolioNewStockTest.java:54)


Results :

Failed tests: deleteStock(com.qtpselenium.framework.SuiteB.AddPortFolioNewStoc
kTest)

Tests run: 10, Failures: 1, Errors: 0, Skipped: 6

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.840 s
[INFO] Finished at: 2016-07-31T16:37:28-05:00
[INFO] Final Memory: 12M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
12.4:test (default-test) on project Core_Hybrid_Framework: There are test failur
es.
[ERROR]
[ERROR] Please refer to C:\Users\CHOWDHURY\maven\Core_Hybrid_Framework\target\su
refire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption

M
Replied on 31/07/2016

send a screen shot of line 514 in Keywords.java


M
Replied on 01/08/2016

[attachment=0:2jsbrya6]line514_keywords.java[/attachment:2jsbrya6]


M
Replied on 01/08/2016

actually this is code in line 514 in bold:
public void takeScreenshot(){
String filepath=Constants.SCREENSHOTPATH+currentTestName+"-"+currentIteration+".png";
File targetFile= new File(filepath);
[b:39uneng8]File srcFile=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);[/b:39uneng8]
try {
FileUtils.copyFile(srcFile, targetFile);
} catch (IOException e) {
e.printStackTrace();
}


M
Replied on 02/08/2016

try to use this and see if error comes.
public void takeScreenshot() throws IOException{
File targetFile = new File(filepath);
File scrFile = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, targetFile);
}