microsoft / WinAppDriver

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

WinAppDriver finds Element but fails to Click it #996

Open schrdori opened 4 years ago

schrdori commented 4 years ago

Hello,

When performing Tests on a Remote, i can find the element but i can't click it.

Building the Session works.

var options = new AppiumOptions();
    options.AddAdditionalCapability("app", appPath);
var driver =  new WindowsDriver<AppiumWebElement> 
    (new Uri(WinAppDriverCommunicationUrl), options, timeout);

Finding the Element works!

var element = driver.FindElementByName(name);
// as well as:
var child = element.FindElementByName(name);

Now the Element even has Coordinates. But right on the .Click() Method a WebDriverException is thrown.

i am getting 2 different Errors. For AppiumWebElement.Click();

OpenQA.Selenium.WebDriverException: An unknown error occurred in the remote end while processing the command.
  Stack Trace: 
    RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
    RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
    AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
    RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
    RemoteWebElement.Click()
    [...]

and for the Action:

var action = new Actions(Appium.WrappedDriver);
action.Click(Appium).Perform();
    OpenQA.Selenium.WebDriverException: Access is denied
  Stack Trace: 
    RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
    RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
    AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
    RemoteMouse.MouseMove(ICoordinates where)
    MoveMouseAction.Perform()
    CompositeAction.Perform()
    Actions.Perform()
    WinAppElement.Click() line 67

This is probably somehow connected to #147 but i can open a Session. A Workaround is to Unlock the remote pc screen (or build up a Remote Desktop Connection) before executing the tests. winappdriver-console-stack.txt

clintmasden commented 4 years ago

You are correct that the remote PC has to have an active desktop session, and i've accomplished this by starting a RDP session before levering WinAppDriver. If the remote machine is going to be test machine you could do the following: https://betanews.com/2015/07/29/automate-login-and-bypass-the-lock-screen-in-windows-10/ | yet you'll need another program to set the resolution to 1920x1080 for example, since I believe it starts at 720×480.