Not able to take screenshot of alert box in Katalon.
I know that even selenium doesn’t support it. But there are work around to achieve it … but those screenshots wouldn’t be part of the Report.
Please suggest.
Not able to take screenshot of alert box in Katalon.
I know that even selenium doesn’t support it. But there are work around to achieve it … but those screenshots wouldn’t be part of the Report.
Please suggest.
You could test for the alert box with WebUI.waitForAlert(5)
You could get the text of the alert with WebUI.getAlertText()
If you put that in an IF statement, you could take a screenshot once the alert is detected.
elementPresent=WebUI.waitForAlert(5)
if (elementPresent==true) {
alertText = WebUI.getAlertText()
WebUI.takeScreenshot()}
Peter Wilson said:
You could test for the alert box with WebUI.waitForAlert(5)
You could get the text of the alert with WebUI.getAlertText()
If you put that in an IF statement, you could take a screenshot once the alert is detected.elementPresent=WebUI.waitForAlert(5)
if (elementPresent==true) {
alertText = WebUI.getAlertText()
WebUI.takeScreenshot()}
Thanks for your reply Peter. But it doesn’t work. I am getting the below error.
Test Cases/0_JavaScriptAlert FAILED because (of) Cannot take screenshot (Root cause: org.openqa.selenium.UnhandledAlertException: unexpected alert open: {Alert text : I am the Javascript} (Session info: chrome=67.0.3396.79) (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
I am also trying to take screenshot with the browser alert, but failed. I need this screenshot as proof of fixes. Anyone pls help? Thanks.
Cannot take screenshot (Root cause: org.openqa.selenium.UnhandledAlertException: unexpected alert open:
Check the below link for answer. But this a workaround.