Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove empty action #2431

Closed

Conversation

kkb912002
Copy link

from selenium.webdriver.common.action_chains import ActionChains

action = ActionChains(driver)
action.send_keys('abcde').perform()

When performing the above operation, the pointer action(mouse) is filled with zero pauses(according to the W3C specification for isolating time slices between action types). The driver's operation to remove the zero pauses creates an empty action, resulting in the following error from WDA.

Error Domain=com.facebook.WebDriverAgent Code=1 "It is mandatory to have at least one gesture item defined for each action. Action with id 'mouse' contains none" UserInfo={NSLocalizedDescription=It is mandatory to have at least one gesture item defined for each action. Action with id 'mouse' contains none}

Until WDA fully supports W3C ActionChains, this exception handling might be necessary.

I am unsure how to execute the e2e test code, so I am providing a rough version of the test code here.

it('should send keys', async () => {
  const pointer = driver
    .action('pointer', {id: 'mouse'})
    .pause(0)
    .pause(0)
    .pause(0)
    .pause(0)
    .pause(0)
    .pause(0);
  const key = driver
    .action('key', {id: 'key'})
    .down('a')
    .up('a')
    .down('b')
    .up('b')
    .down('c')
    .up('c');

  await driver.actions([pointer, key]);
});

@KazuCocoa
Copy link
Member

Just a question: does the action.send_keys('abcde').perform() send both pointer and key as the default behavior? so, it does not send a single key type.

[
  {
    "type": "key",
    "id": "keyboard",
    "actions": [
      {
        "type": "keyDown",
        "value": "a"
      },
      {
        "type": "keyUp",
        "value": "a"
      }
    ]
  }
]

e.g. driver.key_action.send_keys('a').perform in ruby_lib_core

Then, perhaps it would be nice to update e2e below to add the both (default selenium client) case in addition to current test code.

const actions = [
{
type: 'key',
id: 'keyboard',
actions: [
{type: 'keyDown', value: 'h'},
{type: 'keyUp', value: 'h'},
{type: 'keyDown', value: 'i'},
{type: 'keyUp', value: 'i'},
{type: 'keyDown', value: 'あ'},
{type: 'keyUp', value: 'あ'},
],
},
];
await driver.performActions(actions);

I also wondered if just ignoring behaviour in https://github.com/appium/WebDriverAgent/blob/2a1a4e78f51de11a8cb4197dfbaa075b8d035705/WebDriverAgentLib/Utilities/FBW3CActionsSynthesizer.m#L724 (for an empty array) would also be proper. So the error is for non-actions/non-list one only, empty array is not matter. (I'll take a look at the WDA side tonight)

@KazuCocoa
Copy link
Member

KazuCocoa commented Jul 20, 2024

xcuitest driver 7.24.1 should work for this case at least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants