28 Temmuz 2014 Pazartesi

Selenium Resim çekme

Selenium ile webbrowserın resmini çekme.Selenium screen alma ile ilgili konu
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com.tr/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\resim.png"));

 public void TakeScreenshot()
{
    try
    {            
        Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
        ss.SaveAsFile(@"D:\resim.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
        throw;
    }
}

Hiç yorum yok:

Yorum Gönder