microsoft / WinAppDriver

Windows Application Driver
MIT License
3.66k stars 1.4k forks source link

TouchScreen always throw System.InvalidOperationException #839

Open gis2all opened 5 years ago

gis2all commented 5 years ago

I want to simulate the mouse scrolling action, but I found that throwing an exception whenever I use the TouchScreen class.

Here I debug the WebDriverAPI example unit test and I get this error:

image Error message in cmd:

{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}

I tried to troubleshoot

  1. WinAppDriver.msi version, I have installed v1.1.1 and v1.1
  2. Nuget package: Microsoft.WinAppDriver.Appium.WebDriver Selenium.Support and Selenium.WebDriver -- I tried 3.8.0, 3.9.0, 3.10.0, 3.14.0
  3. Close Window Firewall and Defender
  4. Run WinAppDriver.exe and VS2017 with administrator privileges

But the above attempts have failed, and the issue still exists.

My test environment is as follows

  1. Window 10 Enterprise Version 1809 (OS Build 17763.720)
  2. Visual Studio 2017 Professional 15.9 Release
  3. WinAppDriver.exe v1.1.1
  4. Nuget Microsoft.WinAppDriver.Appium.WebDriver 1.0.1-Preview Selenium.Support 3.8.0 Selenium.WebDriver 3.8.0
hassanuz commented 5 years ago

Hi @Assault72,

Can you please paste what WinAppDriver.exe console logs are showing?

A successful response should look something like the following:

========================================== POST /session/0A543F58-F490-4D6A-8690-B4FF7A48D4CA/touch/click HTTP/1.1 Accept: application/json, image/png Content-Length: 28 Content-Type: application/json;charset=utf-8 Host: 127.0.0.1:4723

{"element":"42.722532.4.16"} HTTP/1.1 200 OK Content-Length: 63 Content-Type: application/json

{"sessionId":"0A543F58-F490-4D6A-8690-B4FF7A48D4CA","status":0}

==========================================

Can you also try using the Actions API and see if you are able to perform a touch action using it? Check out our ActionsTouch tests as reference.

Thanks

gis2all commented 5 years ago

@hassanuz Response as below:

POST /session/770D500C-940B-4C97-B71C-9898E9E60ACC/touch/click HTTP/1.1 Accept: application/json, image/png Content-Length: 29 Content-Type: application/json;charset=utf-8 Host: 127.0.0.1:4723

{"element":"42.1314982.4.15"} 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."}}

Try work with TouchActions, thow this exception

image

I guess the app itself needs to support part of the touch interfaces in Selenium. If it doesn't implement these interfaces, can't call the relevant API.

FrankieHoomer commented 4 years ago

@gis2all Try to create a wrapper over WindowsDriver and implement the IHasTouchScreen interface like follows:

    public class WindowsExtendedDriver : WindowsDriver<WindowsElement>, IHasTouchScreen
    {
        public WindowsExtendedDriver(Uri remoteAddress, AppiumOptions AppiumOptions) : base(remoteAddress, AppiumOptions)
        {
            TouchScreen = new RemoteTouchScreen(this);
        }

        public ITouchScreen TouchScreen { get; }
    }