appium / appium-for-mac

[deprecated] Application for automating a mac app with JSON wire protocol
Apache License 2.0
193 stars 70 forks source link

[W3C] Does not support sending keys to active element for Mac #80

Open reder9 opened 4 years ago

reder9 commented 4 years ago

Hi, it appears to me that sendKeys isn't working properly on Mac. I have ran the same code on Windows and its able to send the keys just fine.

When I try to send keys on Mac I get the following error: org.openqa.selenium.UnsupportedCommandException: Could not find selector (post_actions:data:) for path '/session/CI8a86aw/actions'. Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: 'OSX-1013-HighSierra-152.local', ip: 'fe80:0:0:0:4f0:6303:f931:2e0%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '11.0.2' Driver info: io.appium.java_client.AppiumDriver Capabilities {app: System Preferences, deviceName: Mac, javascriptEnabled: true, newCommandTimeout: 300, noReset: false, platform: MAC, platformName: Mac} Session ID: 8f851fc5-51f8-456c-8bb9-5958a4342a83 at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35) at org.openqa.selenium.remote.RemoteKeyboard.sendKeys(RemoteKeyboard.java:38) at org.openqa.selenium.interactions.SendKeysAction.perform(SendKeysAction.java:56) at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:34) at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:642) at com.test42.fixture.desktop.test_api.Application.sendKeys(Application.java:370) at com.test42.fixture.desktop.commands.SendKeys.execute(SendKeys.java:52) at com.test42.framework.Command.executeCommand(Command.java:1177) at com.test42.framework.FixtureState.executeCommand(FixtureState.java:695) at com.test42.console.runner.RunnerConnection.lambda$processExecuteCommand$0(RunnerConnection.java:274) at java.base/java.lang.Thread.run(Thread.java:834)

KazuCocoa commented 4 years ago

The error happened when macOS could not find the element by https://developer.apple.com/documentation/objectivec/nsobject/1571960-methodsignatureforselector


https://github.com/appium/appium-for-mac/blob/6763cbffb0fd07369b58868fe6e9e92b23ebb100/AppiumForMac/Server/Handlers/AfMHandlers.m#L1085

reder9 commented 4 years ago

Should I need an element if I'm just sending keys to the desktop? If so that seems a bit funny to me. I'm not trying to enter text into an element, I just want to be able to send off keystrokes to help automate things. For example sending arrow keys to navigate around an app etc.

KazuCocoa commented 4 years ago

I noticed maybe you meant W3C actions' send keys.

For macOS has a command for session/:session_id/keys which is send keys to active element in MJSONWP spec https://github.com/appium/appium-for-mac/blob/6763cbffb0fd07369b58868fe6e9e92b23ebb100/AppiumForMac/Server/Handlers/AfMHandlers.m#L695-L704

KazuCocoa commented 4 years ago

This root cause is this repository does not support /actions for send keys to the active elements command as W3C yet. Java client sends the /actions as the command instead of session/:session_id/keys. session/:session_id/keys is MJSONWP.

As a workaround in Java client, you can try forceMjsonwp as https://github.com/appium/java-client/issues/969#issuecomment-436124152 . Then, Java client works as MJSONWP.