Some queries...... | Selenium Forum
M
Posted on 24/04/2016
Query1:
Am using a data driven framework, now i used a assert in a scenario & test failed.
Now i need screenshot to be taken for all the [b:189ljfo5]failed tests only[/b:189ljfo5] .So, where is screenshot capturing code placed in framework ?

Query2:
i have a web application, now a alert appears very inconsistently irrespective of scenario, how do u handle that alert?
[b:189ljfo5]Had answered: Set in profile property to accept alerts.[Answer Was not matching expectations ]
where is such alert handling code placed in framework ?[/b:189ljfo5]

M
Replied on 26/04/2016

query 1: create function yourself in which selenium that takes the screen shot and when ever test fails call that function.


M
Replied on 26/04/2016

k....sir ....

Call capturescreenshot(String filename) in onTestFailure method of Listeners....


//*****Generic methods********
public void capturescreenshot(String filename) throws IOException{
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(System.getProperty("user.dir")+"\\screenshots\\"+filename+".jpg"));


Got it sir..Thankz alot....


}