[英]How to create a log file using selenium webdriver and C#?
How to create a log file using selenium webdriver? 如何使用Selenium WebDriver创建日志文件? I had created a log file using selenium RC.
我已经使用Selenium RC创建了一个日志文件。 IN selenium RC I had created an HTML log file with screenshots and error messages.
在selenium RC中,我创建了一个包含屏幕截图和错误消息的HTML日志文件。 I used the following code in selenium RC.
我在硒RC中使用了以下代码。
`selenium.CaptureEntirePageScreenshot(screenShotDirectory + "\\" + "wrong username and password.png",""); `selenium.CaptureEntirePageScreenshot(screenShotDirectory +“ \\” +“用户名和密码错误。png”,“”);
string path = "Screenshot\\wrong username and password.png"; 字符串路径=“屏幕截图\\错误的username和password.png”;
Sw.WriteLine(" Wrong username and password
Sw.WriteLine(“ 用户名和密码错误
"); ` “);`
How can I create same HTML log file using selenium Webdriver? 如何使用Selenium Webdriver创建相同的HTML日志文件? What code in C# should i write?
我应该用C#编写什么代码?
Thanks. 谢谢。
In the .NET bindings, you'll want something like the following: 在.NET绑定中,您将需要以下内容:
// Assumes driver is a WebDriver instance that implements ITakesScreenshot
// N.B., to be completely correct, you should check for a successful cast
// by adding a null check for screenshotDriver.
ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;
Screenshot screenCapture = screenshotDriver.GetScreenshot();
screenCapture.SaveAsFile(screenShotDirectory + "\\" + "wrongUserNameAndPassword.png",
System.Drawing.Imaging.ImageFormat.Png);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.