selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[py] support wheel also to build sync actions

Open kkb912002 opened this issue 1 year ago • 4 comments

Description

Make ActionChains.scroll_* functions fill pause to key, pointer actions queue each for building sync actions. And make the other functions fill pause to scroll actions queue also.

Motivation and Context

Problem: When run the code below, pause actions are carried out differently than intended.

actions = ActionChains(driver)
actions.scroll_...()
actions.pause(5)
actions.scroll_...()
actions.pause(5)
actions.scroll_...()
actions.perform()

Built actions:

[
  { type: "pointer", .., actions: [{ type: "pause", duration: 5000 }, { type: "pause", duration: 5000 }],
  { type: "key", ......, actions: [{ type: "pause", duration: 5000 }, { type: "pause", duration: 5000 }],
  { type: "wheel", ...., actions: [{ type: "scroll", .. }, { type: "scroll", .. }, { type: "scroll", .. }]
]

Should be(simplified):

[
  { type: "pointer", .., actions: [{ pause 0 }, { pause 5000 }, { pause 0 }, { pause 5000 }, { pause 0 }],
  { type: "key", ......, actions: [{ pause 0 }, { pause 5000 }, { pause 0 }, { pause 5000 }, { pause 0 }],
  { type: "wheel", ...., actions: [{ scroll }, { pause 5000 }, { scroll 0 }, { pause 5000 }, { scroll 0 }]
]

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [x] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • [x] I have read the contributing document.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have added tests to cover my changes.
  • [x] All new and existing tests passed.

kkb912002 avatar Feb 23 '24 06:02 kkb912002

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 23 '24 06:02 CLAassistant

Can you add a test that shows what you're after and that passes after this change? Looking at the code I don't think it is doing what you're after but would like to see a test in case I am missing something

AutomatedTester avatar Feb 23 '24 11:02 AutomatedTester

Can you add a test that shows what you're after and that passes after this change? Looking at the code I don't think it is doing what you're after but would like to see a test in case I am missing something

I modified the existing test case to fail on the trunk branch.

On the trunk: pointerDown and scroll actions are performed at the same time.

[
  { type: "pointer", .., actions: [{ pointerDown }, { pointerUp }, { pause 0 },   { pause 0 }, { pause 0 } ...],
  { type: "key", ......, actions: [{ pause 0 },     { pause 0 },   { keyDown f }, { keyUp f }, { keyDown o } ...],
  { type: "wheel", ...., actions: [{ scroll }]
]

Fixed:

[
  { type: "pointer", .., actions: [{ pointerDown }, { pointerUp }, { pause 0 }, { pause 0 },   { pause 0 }, { pause 0 } ...],
  { type: "key", ......, actions: [{ pause 0 },     { pause 0 },   { pause 0 }, { keyDown f }, { keyUp f }, { keyDown o } ...],
  { type: "wheel", ...., actions: [{ pause 0 },     { pause 0 },   { scroll },  { pause 0 },   { pause 0 }, { pause 0 } ...]
]

kkb912002 avatar Feb 26 '24 03:02 kkb912002

@AutomatedTester Isn't this enough?

kkb912002 avatar Mar 17 '24 23:03 kkb912002