Hi All,
I have written the below code to capture the screen shot of a whole webpage.
But I'm able to capture only the partial/visible part of the webpage displayed not the whole webpage. Please suggest.
Im Using:
Selenium WebDriver Version: 3.0.0-beta3
Firefox Version: 49.0.1
OS: Win10
package Selenium_WebDriver_Part1; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class Quikr { public static WebDriver driver=null; @Test public void loginTest() throws InterruptedException, IOException{ System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe"); driver = new FirefoxDriver(); driver.get("http://www.quikr.com/"); driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS); takeScreenShot("LoginPage"); } public static void takeScreenShot(String fileName) throws IOException{ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy hh mm ss"); String time = dateFormat.format(now); String resDir = System.getProperty("user.dir")+"\\"+time; File resFolder = new File(resDir); resFolder.mkdir(); File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); // Now you can do whatever you need to do with it, for example copy somewhere FileUtils.copyFile(scrFile, new File(resDir+"\\"+fileName+".jpeg")); } }