Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Add methods for scrolling to top and bottom of edit form panel #277

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Context/BasicContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,.cms #Form_ItemEditForm > .panel');",
"el.scrollTo(0, Math.max(el.scrollHeight, el.scrollHeight, el.clientHeight));",
]);
$this->getSession()->executeScript($javascript);
}

/**
* @Given /^I scroll to the top$/
*/
Expand All @@ -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,.cms #Form_ItemEditForm > .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.
Expand Down
Loading