我在 GDI+ 中发生了 selenium webdriver 的一般错误。昨天它还可以正常工作,但突然我得到了这个错误。
public string TakeScreenshot(IWebDriver driver, string SnapFolderPath, string TCID, string KeyFunction)
{
try
{
// driver.Manage().Window.Maximize();
ITakesScreenshot ssdriver = driver as ITakesScreenshot;
Screenshot screenshot = ssdriver.GetScreenshot();
string filePath = testReport + "\\" + TCID + "_" + KeyFunction + "_" + GetDateTimeforFilePath() + ".png";
screenshot.SaveAsFile(filePath, ImageFormat.Png);
return filePath;
}
catch (Exception ex)
{
return string.Empty;
}
}