Skip to content

Browser test helper: isBlockVisible #7346

@rachel-fenichel

Description

@rachel-fenichel

Add a helper to check whether a block is visible, meaning inside the bounds of the Blockly div.

Basic code looks like this:

const isVisible = await browser.execute((elem) => {
  const rect = elem.getBoundingClientRect()

  const blocklyDiv = document.getElementById('blocklyDiv');
  const blocklyRect = blocklyDiv.getBoundingClientRect();

  const vertInView = (rect.top >= blocklyRect.top) && (rect.bottom <= blocklyRect.bottom);
  const horInView = (rect.left >= blocklyRect.left) && (rect.right <= blocklyRect.right);

  return (vertInView && horInView)
}, flyoutBlock);

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