是的,我們絕對可以拍攝多張截圖。瀏覽器是處於最小化還是最大化狀態並沒有影響。只要你必須切換新的打開的窗口&添加「採取截圖」方法後,你必須採取截圖每個方法。
當瀏覽器處於「最小化」或「最大化」狀態時,屏幕截圖方法可以在兩種模式下工作。 對於截圖可以可以使用下面的代碼:
public void getscreenshot() throws Exception
{
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
//The below method will save the screen shot in d drive with name "screenshot.png"
FileUtils.copyFile(scrFile, new File("D:\\screenshot.png"));
}
,或者你可以選擇多屏幕捕獲和該代碼如下:
public void GoogleAbout() throws Exception {
driver.get(baseUrl); // Enter the URL as per your choice
driver.findElement(By.linkText(Prop.getProperty("AboutLinkText"))).click(); //find the web element
MultiScreenShot multiScreens = new MultiScreenShot("C:\\New\\","GoogleAbout"); // Here we need to create the object which will take two arguement one is the path to save the file and second one is class name
multiScreens.multiScreenShot(driver);
driver.findElement(By.linkText("More about our philosophy")).click();
multiScreens.multiScreenShot(driver);
}
啓用多屏幕截圖你必須下載JAR文件,然後將其附加到你的項目中,然後:
import multiScreenShot.MultiScreenShot;
因此,當窗口最小化時,屏幕截圖是否捕獲窗口中發生的事情? –
我可以從哪裏下載** MultiScreenShot ** jar文件? –
哦,順便說一下,我正在尋找屏幕記錄(視頻)現實不截圖(picturs) –