Skip to content

Browser test helper: scroll flyout #7347

@rachel-fenichel

Description

@rachel-fenichel

Add a helper to scroll the flyout using the scrollbar.

Basic code looks like this:

/**
 * Find the flyout's scrollbar and scroll by the specified amount.
 * This makes several assumptions:
 *  - A flyout with a valid scrollbar exists, is open, and is in view.
 *  - The workspace has a trash can, which means it has a second (hidden) flyout.
 * @param browser The active WebdriverIO Browser object.
 * @param xDelta How far to drag the flyout in the x direction. Positive is right.
 * @param yDelta How far to drag thte flyout in the y direction. Positive is down.
 * @return A Promise that resolves when the actions are completed.
 */
async function scrollFlyout(browser, xDelta, yDelta) {
  // There are two flyouts on the playground workspace: one for the trash can
  // and one for the toolbox. We want the second one.
  // This assumes there is only one scrollbar handle in the flyout, but it could 
  // be either horizontal or vertical.
  await browser.pause(50);
  const selected = await browser.$$(`.blocklyFlyoutScrollbar`)[1].$(`rect.blocklyScrollbarHandle`);
  await browser.pause(50);
  await selected.dragAndDrop({x: xDelta, y: yDelta});
  await browser.pause(50);
}

Some error handling for a missing or invisible flyout scrollbar would be helpful.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions