Scenario 1:
-----------
When Try with selenium-server-standalone-3.14.jar to
take the screenshot.
Refer the code:
---------------
File scrFile =
((TakesScreenshot)d).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("D:\\path\\screenshot.png"));
Scenario 2:
-----------
When Try with selenium-server-standalone-3.141.59(Latest
Version).jar to take the screenshot.
It doesnot support the FileUtils.copyFile replace that it
support Files.copy
File scrFile = ((TakesScreenshot)d).getScreenshotAs(OutputType.FILE);
Files.copy(scrFile, new
File("D:\\path\\screenshot.png"));
Note:
Both scenario 1 and scenario 2
it does not take the screenshot of entire page.
Scenario 3:
-----------
To Take the Entire page of
screenshot.
1)To create a Maven Projet.
2)Add the Dependency
Selenium-shutterbug in POM.xml file.
<!--
https://mvnrepository.com/artifact/com.assertthat/selenium-shutterbug -->
<dependency>
<groupId>com.assertthat</groupId>
<artifactId>selenium-shutterbug</artifactId>
<version>0.9</version>
</dependency>
3)Create a Class and Implement
the Code.
package Screen;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
com.assertthat.selenium_shutterbug.core.Shutterbug;
import
com.assertthat.selenium_shutterbug.utils.web.ScrollStrategy;
public class Take {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","D:\\chromedriver_win32\\chromedriver.exe");
WebDriver d = new ChromeDriver();
d.get("https://www.seleniumhq.org/download/");
Shutterbug.shootPage(d,ScrollStrategy.BOTH_DIRECTIONS,500,true).withName("FullPageScreenshot").save();
d.quit();
}
}
4)After exeute the code Right click the project folder and refersh it
then it generate the folder "Screenshot" and open your screenshot
file.
Hi when i am runnnig the above code i am getting an
ReplyDeleteerror:
java.lang.NoSuchMethodError: com.assertthat.selenium_shutterbug.core.Shutterbug.shootPage(Lorg/openqa/selenium/WebDriver;Lcom/assertthat/selenium_shutterbug/utils/web/ScrollStrategy;IZ)Lcom/assertthat/selenium_shutterbug/core/PageSnapshot;
Can anyone help me what is the issue.I have added the maven dependency as well