query 1: create function yourself in which selenium that takes the screen shot and when ever test fails call that function.
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....
}