I am new to Selenium, and I am stuck with Selenium taking screenshots when Assert equals fails. I am using TestNG.
When testcase fails on server side, it needs to take a screenshot of a page, so that i can exactly know where it went wrong.
I wrap the code in try catch block and in catch, I am taking a screenshot.
The Screenshot feature is working when O see selenium issues such as, where the element not visible, Unable to click on an element.
But this is failing for Assert.equals(). When Assert.assertEquals() fails, I am expecting it goes to catch and takes a screenshot. Can anyone please clarify my doubts?
Below is the code snippet, how I am trying to achive this:
try {
Assert.assertEquals(expected,actualoutput,message) //it fails
}
catch {
Selenium taking screenshot // iam not able to take screenshot
}
While the comments are true, I offer you workaround – change
Asserttoif: