本文介绍了使用selenium C#获取完整的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下代码来截取可见页面的截图。

我的目标是获取整页截图。

Cal有人帮我这个吗?



我尝试过:



//请在下面找到当前代码



public void TakeScreenshot(String path,String imgName)

{



截图ss =((ITakesScreenshot)驱动程序).GetScreenshot();



// String dir = path;

String filepath = path;



if(!Directory.Exists(filepath))

Directory.CreateDirectory(filepath);



ss.SaveAsFile(filepath + imgName +。png,ScreenshotImageFormat.Png);



}

I have already the following code which is taking the screenshot of the visible page.
My goal is taking a full page screenshot instead .
Cal someone help me with this ?

What I have tried:

// please find below the Current code

public void TakeScreenshot(String path, String imgName)
{

Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();

//String dir = path;
String filepath = path;

if (!Directory.Exists(filepath))
Directory.CreateDirectory(filepath);

ss.SaveAsFile(filepath + imgName + ".png", ScreenshotImageFormat.Png);

}

推荐答案

public void TakeScreenshot(String url, String image)
{
	var driver = new InternetExplorerDriver();
	driver.Navigate().GoToUrl(url);
	var ss = driver.GetScreenshot();
	ss.SaveAsFile(image, System.Drawing.Imaging.ImageFormat.Png);
}


这篇关于使用selenium C#获取完整的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 13:12