Вот мой код.
TakeScreenshot.java
Код: Выделить всё
public class Takescreenshot
{
private static final File SrcnewFile = null;
public static void main(String[] args) throws Exception
{
WebDriver driver ;
WebDriverManager.chromedriver().clearCache();
//System.setProperty("webdriver.chrome.driver","C:\drivers/chromedriver.exe");
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.get("https://www.amazon.in/");
TakesScreenshot scrShot =((TakesScreenshot)driver);
File SrcFile=scrShot.getScreenshotAs(OutputType.FILE);
if(null!=null)
{
File DestFile=new File("c:test/test1.png");
FileUtils.copyFile(SrcFile, DestFile);
FileUtils.getFile(SrcnewFile, ("c://test1.png"));
driver.quit();
}
}
}
Код: Выделить всё
Starting ChromeDriver 98.0.4758.80 (7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758@{#972}) on port 58811
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Feb 15, 2022 12:53:33 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Feb 15, 2022 12:53:33 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 98, so returning the closest version found: 97
Feb 15, 2022 12:53:33 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 98 of 97
Код: Выделить всё
com.google.guava
guava
31.0.1-jre
commons-io
commons-io
2.7
org.seleniumhq.selenium
selenium-java
4.1.2
io.github.bonigarcia
webdrivermanager
3.6.2
Подробнее здесь: https://stackoverflow.com/questions/711 ... turning-th