flow behaviors: add scrolling into view (#892)

Some page elements don't quite respond correctly if the element is not
in view, so should add the setEnsureElementIsInTheViewport() to click,
doubleclick, hover and change step locators.
This commit is contained in:
Ilya Kreymer 2025-10-07 08:17:56 -07:00 committed by GitHub
parent cc2d890916
commit fd49041f63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 7 deletions

View file

@ -368,7 +368,7 @@ class Flow {
case StepType.DoubleClick:
await locator(step)
.setTimeout(timeout * 1000)
//.on('action', () => startWaitingForEvents())
.setEnsureElementIsInTheViewport(true)
.click({
count: 2,
button: step.button && mouseButtonMap.get(step.button),
@ -392,7 +392,7 @@ class Flow {
await locator(step)
.setTimeout(timeout * 1000)
//.on('action', () => startWaitingForEvents())
.setEnsureElementIsInTheViewport(true)
.click({
delay: step.duration,
button: step.button && mouseButtonMap.get(step.button),
@ -410,7 +410,7 @@ class Flow {
case StepType.Hover:
await locator(step)
.setTimeout(timeout * 1000)
//.on('action', () => startWaitingForEvents())
.setEnsureElementIsInTheViewport(true)
.hover();
break;
@ -426,15 +426,14 @@ class Flow {
case StepType.Change:
await locator(step)
//.on('action', () => startWaitingForEvents())
.setTimeout(timeout * 1000)
.setEnsureElementIsInTheViewport(true)
.fill(step.value);
break;
case StepType.Scroll: {
if ("selectors" in step) {
await locator(step)
//.on('action', () => startWaitingForEvents())
.setTimeout(timeout * 1000)
.scroll({
scrollLeft: step.x || 0,

View file

@ -43,8 +43,8 @@ test("test custom selector crawls JS files as pages", async () => {
]);
const expectedExtraPages = new Set([
"https://www.iana.org/_js/jquery.js",
"https://www.iana.org/_js/iana.js",
"https://www.iana.org/static/_js/jquery.js",
"https://www.iana.org/static/_js/iana.js",
]);
expect(pages).toEqual(expectedPages);