1

How to take screenshots for pop-up window by using selenium. I'm using only Firefox. 1st I was login web site and replace the address details after that update successful pop-up is came so I want to take screenshots for that one.

I used java language

  • 1
    Welcome to SO. Please take the time to read [ask]. It will help you craft solid questions that will hopefully get useful answers. What language are you using? – orde Jul 10 '19 at 16:33

1 Answers1

1

For the pop-up window you'll actually need to switch to a new window/pop-up/iframe that appears and you can do that with selenium window handling you can go through new windows, pop-ups, alerts and all.

You can start learning about the window handling just check here

Then after you switched to the new window just take the screenshot.

import org.openqa.selenium.*;    
import org.openqa.selenium.firefox.*;
import org.apache.commons.io.FileUtils;

WebDriver driver = new FirefoxDriver();
driver.get("https://www.wikipedia.org/");

/* Here we would have the switching to the new pop-up window (Window handling) code */

File file = ((TakeScreenshot) driver).getScreenshotAs(OutputType.FILE);
try{
    FileUtils.copyFile(file, new File(location_for_the_file));
}
catch(IOException e){
    e.printStackTrace();
}

If you are still having problems you can check java example and here as a python example .

sirfelipe
  • 31
  • 6