public void WhenSetClipboardContentTypeIsImage_GetClipboardShouldReturnEncodedBase64String() { var testImageBytes = _driver.GetScreenshot().AsByteArray; var base64Image = Convert.ToBase64String(testImageBytes); _driver.SetClipboard(ClipboardContentType.Image, base64Image); Assert.That(() => Regex.IsMatch(_driver.GetClipboard(ClipboardContentType.Image), Base64RegexPattern, RegexOptions.Multiline), Is.True); }
private void CreateScreenshot() { var screenshot = driver.GetScreenshot(); screenshot.SaveAsFile("startScreen.png", OpenQA.Selenium.ScreenshotImageFormat.Png); ctx.AddResultFile("startScreen.png"); }
public void ErrorGetClosedWindowScreenshot() { // Launch calculator for this specific test case DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", CommonTestSettings.CalculatorAppId); IOSDriver <IOSElement> calculatorSession = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(calculatorSession); Assert.IsNotNull(calculatorSession.SessionId); try { calculatorSession.Close(); calculatorSession.GetScreenshot(); Assert.Fail("Exception should have been thrown because there is no such window"); } catch (System.InvalidOperationException exception) { Assert.AreEqual("Currently selected window has been closed", exception.Message); } calculatorSession.Quit(); calculatorSession = null; }
public void GetScreenshot() { var screenshot = session.GetScreenshot(); using (MemoryStream msScreenshot = new MemoryStream(screenshot.AsByteArray)) { Image screenshotImage = Image.FromStream(msScreenshot); Assert.IsTrue(screenshotImage.Height > 0); Assert.IsTrue(screenshotImage.Width > 0); } }
public static Bitmap GetScreenshot() { byte[] picture; MemoryStream ms; Bitmap image = null; switch (PlatForm) { case DeviceType.Android: picture = driver_Android.GetScreenshot().AsByteArray; ms = new MemoryStream(picture); image = new Bitmap(ms); break; case DeviceType.IOS: picture = driver_IOS.GetScreenshot().AsByteArray; ms = new MemoryStream(picture); image = new Bitmap(ms); break; } return(image); }