Selenium tests unable to capture screenshot when alert is raised.
I set the desired capability too.
chromeOptions.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, "ignore");
But the script failing at 2nd line. Tried applying explicit waits too but no use.
driverManager.getWebDriver().switchTo().alert();
byte[] screenshot = ((TakesScreenshot) driverManager.getWebDriver()).getScreenshotAs(OutputType.BYTES);
scenario.attach(screenshot, "image/png", "attachment-"+LocalTime.now().toSecondOfDay());
driverManager.getWebDriver().switchTo().defaultContent();
Other stack overflow articles doesn't seem to help. Is there any solution for this? Are there any popular 3rd party libraries can be used for this purpose?