Screen shots are important to have in the results analysis of test cases. By looking at the captured screen shots we can tell what went wrong or what could be reason for a test case failure.
Selenium WebDriver provides TaskesScreenShot interface to capture the screen shots. This interface is available under package import org.openqa.selenium.TakesScreenshot.
The below test script explains how to capture the screen shot when a test case is failed. The below script launches Gmail login page and tries to enter the username to Email or Phone filed with an invalid id. Since there is no element with the given id on the page it's throws an exception. In the exception block captureScreenShot() method will be called to take the screen shot.
Note: Using TakesScreenshot inSelenium WebDriver we can capture only visible area. What if we want to capture entire page? or What if we want capture particular WebElement as screen shots? We will see that in the next post.
Selenium WebDriver provides TaskesScreenShot interface to capture the screen shots. This interface is available under package import org.openqa.selenium.TakesScreenshot.
The below test script explains how to capture the screen shot when a test case is failed. The below script launches Gmail login page and tries to enter the username to Email or Phone filed with an invalid id. Since there is no element with the given id on the page it's throws an exception. In the exception block captureScreenShot() method will be called to take the screen shot.
Note: Using TakesScreenshot inSelenium WebDriver we can capture only visible area. What if we want to capture entire page? or What if we want capture particular WebElement as screen shots? We will see that in the next post.
No comments:
Post a Comment