MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / interactableCentre

Function interactableCentre

javascript/atoms/typescript/click.ts:43–53  ·  view source on GitHub ↗
(element: Element)

Source from the content-addressed store, hash-verified

41// An element with no area of its own (an empty inline wrapper, say) is aimed
42// at through its offsetParent's size, as bot.action.getInteractableSize did.
43function interactableCentre(element: Element): Coordinate {
44 let node: Element = element
45 for (;;) {
46 const rect = getClientRect(node)
47 const parent = (node as HTMLElement).offsetParent
48 if ((rect.width > 0 && rect.height > 0) || !parent) {
49 return { x: rect.width / 2, y: rect.height / 2 }
50 }
51 node = parent
52 }
53}
54
55export default click

Callers 1

clickFunction · 0.85

Calls 1

getClientRectFunction · 0.50

Tested by

no test coverage detected