public string CaptureWebPageToFile(string filePath) { // ページイメージをファイルに保存する var now = DateTime.Now; Screenshot shot = null; do { shot = ((ITakesScreenshot )WebDriver).GetScreenshot(); if(DateTime.Now - now >= TimeSpan.FromSeconds(10)) { throw new SpecFlowException( "キャプチャに10秒以上かかりました。" ); } }while(shot.AsByteArray.Length == 0 ); shot.SaveAsFile(filePath, ImageFormat.Png); return filePath; } private
