From 9cd925befaff7967095a01399e54fa65922298d8 Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Wed, 25 Sep 2024 09:46:37 +0800 Subject: [PATCH] fix scrolling makes element invisible (#881) --- skyvern/webeye/scraper/domUtils.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js index 96fd00b7..1caa0b6c 100644 --- a/skyvern/webeye/scraper/domUtils.js +++ b/skyvern/webeye/scraper/domUtils.js @@ -248,12 +248,16 @@ function isElementVisible(element) { return false; } - // if the center point of the element is not in the page, we tag it as an interactable element - const center_x = (rect.left + rect.width) / 2; - const center_y = (rect.top + rect.height) / 2; - if (center_x < 0 || center_y < 0) { + // if the center point of the element is not in the page, we tag it as an non-interactable element + // FIXME: sometimes there could be an overflow element blocking the default scrolling, making Y coordinate be wrong. So we currently only check for X + const center_x = (rect.left + rect.width) / 2 + window.scrollX; + if (center_x < 0) { return false; } + // const center_y = (rect.top + rect.height) / 2 + window.scrollY; + // if (center_x < 0 || center_y < 0) { + // return false; + // } return true; }