Is there a way, not to prompt a new window for your screenshot code when it is in a class ?
This is where I call the class within my code:
findText(By.xpath("//*[text()='Table']")).click
pause(3)
findLink(By.cssSelector("button.btn.btn-link[aria-label='Maximize']")).click
new takesScreenshot();
findLink(By.cssSelector("button.btn.btn-link[aria-label='Dashlet Actions']")).click
This is my class code for screenshot:
public class takesScreenshot {
{
WebDriver driver = new ChromeDriver();
File tempFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(tempFile,new File( "C:\\Screenshots\\"+ "SS1" + ".png"));
} catch (IOException e) {
// TODO handle exception
}
Right now when the class is called it prompts a new window that's why i cannot do screenshot for what i supposed to capture please help thanks!
its because you are starting a new chrome driver instance in your takeScreenshot method. Take out the line:
if you need your driver instance, you may need to pass it into the takeScreenshot method