From 917695bfc5c134e94c13ca947fe59ce4e2659c17 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 4 Jul 2024 17:01:29 +1200 Subject: [PATCH] NEW Add methods for scrolling to top and bottom of edit form panel --- src/Context/BasicContext.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Context/BasicContext.php b/src/Context/BasicContext.php index 0d37c9eb..64b26ceb 100644 --- a/src/Context/BasicContext.php +++ b/src/Context/BasicContext.php @@ -1181,6 +1181,18 @@ public function iScrollToBottom() $this->getSession()->executeScript($javascript); } + /** + * @Given /^I scroll to the bottom of the edit form panel$/ + */ + public function iScrollToTheBottomOfTheEditFormPanel() + { + $javascript = implode('', [ + "var el = document.querySelector('.cms #Form_EditForm > .panel');", + "el.scrollTo(0, Math.max(el.scrollHeight, el.scrollHeight, el.clientHeight));", + ]); + $this->getSession()->executeScript($javascript); + } + /** * @Given /^I scroll to the top$/ */ @@ -1189,6 +1201,18 @@ public function iScrollToTop() $this->getSession()->executeScript('window.scrollTo(0,0);'); } + /** + * @Given /^I scroll to the top of the edit form panel$/ + */ + public function iScrollToTheTopOfTheEditFormPanel() + { + $javascript = implode('', [ + "var el = document.querySelector('.cms #Form_EditForm > .panel');", + "el.scrollTo(0, 0);", + ]); + $this->getSession()->executeScript($javascript); + } + /** * Scroll to a certain element by label. * Requires an "id" attribute to uniquely identify the element in the document.