Imagine that you want to do some in-depth analysis of the UI by taking screenshots. This is something that has been done a number of times in different projects. For example, you take a screenshot, then make changes, and then take more screenshots along the way.
Open up Intellij and create a new Java test class.
We will now add a new line for taking a screenshot:driver.get(http://book.theautomatedtester.co.uk); Bytes screenbytes = ((Screenshot)driver).getScreenshotAs(bytes);
If you set a breakpoint on the previous line, you will be able to see what the string looks like.
What just happened?
Now that we have seen what it takes to take a screenshot of the page from the browser, we have managed to take a screenshot and then push the result into a bytes variable. We can then perform histogram type checks against the bytes and anything else that we want.
We can also push the bytes into a stream to save it to file or we can have a look at taking screenshots straight to files.
Saving screenshots to files
Saving screenshots to file is probably the most common way to save a file. This approach will save the file to disk straight away. When we save the screenshot as a file, we are returned a file object.
We can then use it straight away to do anything like getPath() or do what we need.
Selenium Related Interview Questions
|SILK TEST Interview Questions||QTP Interview Questions|
|JMeter Interview Questions||Automation Testing Interview Questions|
|Software testing Interview Questions||JUnit Interview Questions|
|TestNG Interview Questions||SAP Testing Interview Questions|
|Selenium WebDriver Interview Questions||Selenium IDE Interview Questions|
|QUnit Testing Interview Questions||Performance Testing Interview Questions|
|Hadoop Testing Interview Questions|
Getting Started With Selenium Ide
Overview Of Selenium Webdriver
Working With Webdriver
Getting Started With Selenium Grid
Advanced User Interactions
Working With Html5
Migrating From Remote Control To Webdriver
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.