c# - Best way to take screenshots of tests in Selenium 2? -
I would like a way to get a screenshot of my functional tests, I'm currently using Selenium 2 with C # binding. To make sure the desired page is displayed I want to take a screenshot at the end of the exam. Are there any special tools from which you know that I can include in my C # code which will trigger a screenshot? I could not find a manufactured Selenium 2 solution (without seeing it). To do a screenshot in Selenium 2, you need to do the following:
driver = new firefox driver (); // Driver drivers should work in other browser drivers Navigate (). GoToUrl ("http://www.theautomatedtester.co.uk"); Screenshots SS = ((ITakesScreenshot) driver) .GetScreenshot (); // As you wish it is now string screenshot = ss.AsBase64EncodedString; Byte [] screenshotAsByteArray = ss.AsByteArray; Ss.SaveAsFile ("filename", ImageFormat.Png); // ss.ToString (); // string screenshot = ss.AsBase64EncodedString; use any of the equally manufactured image;
That code should work, because I quickly tested it at IronPathon Replace. See IronPython code below import clr clr.AddReference ("WebDriver.Common.dll") clr.AddReference ("WebDriver.Firefox.dll")
Comments
Post a Comment