I can take a screenshot from a Windows Forms form but if I try to take a screenshot from a child control (e.g. button or edit) I will get HTTP 500
If I do the same stuff in WPF application it works.
==========================================
GET /session/EDB053E6-9F3C-418E-8BA1-9F3C53F094B1/screenshot/42.591710 HTTP/1.1
Accept: application/json, image/png
Cache-Control: no-cache
Host: 127.0.0.1:4723
User-Agent: selenium/3.11.0 (.net windows)
HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json
{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
If I look at WebDriver specification the parameters seems to be incorrect
Should it be
GET /session/EDB053E6-9F3C-418E-8BA1-9F3C53F094B1/element/42.591710/screenshot
I tried that too but did not work.
Any news about this?
I'm experiencing a similar problem. I'm testing an MFC application. My test code:
[TestMethod]
public void TestMethod1()
{
WindowsElement start_button = session.FindElementByAccessibilityId("50014");
OpenQA.Selenium.Screenshot screenshot = start_button.GetScreenshot();
screenshot.SaveAsFile("Test.png");
}
And it fails at GetScreenshot(). The corresponding message in WinAppDriver:
GET /session/22178AD8-4312-4905-A845-2AC2C0CBD743/screenshot/42.1117372 HTTP/1.1
Accept: application/json, image/png
Cache-Control: no-cache
Host: 127.0.0.1:4723
HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json
{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
As stated above by @jaska45 this doesn't seem to be the right command. This should be solved by issue #261 in version 1.0 RC2 but I'm still experiencing the problem. Am I doing something wrong or is there still a bug? Would appreciate it if somebody can help.
Version information:
WinAppDriver: v1.1(.1809.18001)
Appium.Webdriver: v3.0.0.2
Castle.Core: v4.3.1
MSTest.TestAdapter: v1.4.0
MSTest.TestFramework: v1.4.0
Newtonsoft.Json: v12.0.1
Selenium.Support: v3.10.0
I had the same issue when attempting to pass any AppiumWebElement that returned from any location method. I was able to capture an image of the application by passing the instance of the driver to this method as a work around and that worked.
I had the same issue when attempting to pass any AppiumWebElement that returned from any location method. I was able to capture an image of the application by passing the instance of the driver to this method as a work around and that worked.
Yes, that also works for me. Did you also find a way to automatically crop the screenshot?
I had the same issue when attempting to pass any AppiumWebElement that returned from any location method. I was able to capture an image of the application by passing the instance of the driver to this method as a work around and that worked.
Yes, that also works for me. Did you also find a way to automatically crop the screenshot?
Ok, I found a way. Don't know if it is the most efficient way but it works (I'm quite new to C#). I'm sharing the code here in case somebody stumbles on the same issue in the future.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;
using System.Drawing;
[TestMethod]
public void TestMethod1()
{
WindowsElement start_button = session.FindElementByAccessibilityId("50014");
OpenQA.Selenium.Screenshot screenshot_full_screen = session.GetScreenshot();
Rectangle crop_rect = new Rectangle(start_button.Location, start_button.Size);
Bitmap image_full_screen = Image.FromStream(new System.IO.MemoryStream(screenshot_full_screen.AsByteArray)) as Bitmap;
Bitmap image_element = new Bitmap(image_full_screen);
image_element = image_full_screen.Clone(crop_rect, image_full_screen.PixelFormat);
image_element.Save("Test.png");
}
Nice solution,
Don't forget to dispose your bitmaps.
Thx
Most helpful comment
Ok, I found a way. Don't know if it is the most efficient way but it works (I'm quite new to C#). I'm sharing the code here in case somebody stumbles on the same issue in the future.