Skip to content

Conversation

jtnord
Copy link
Member

@jtnord jtnord commented Aug 19, 2025

replacing scroller.js with native selenium code. #2136 (comment)

fixes #2129 (maybe!)

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@jtnord jtnord mentioned this pull request Aug 19, 2025
6 tasks
Comment on lines -3 to -19
var eYCoord = arguments[0];
var eXCoord = arguments[1];
var id = arguments[2];
var footer = document.getElementsByTagName("footer");
var sticker = document.getElementById("bottom-sticker");

// Scroll to the element. It will appear at the top edge of the screen.
// We subtract a bit so as to accommodate fixed position banners at the top
// (e.g. breadcrumbs, tabbars etc), making sure they are not hiding the element.
window.scrollTo(eXCoord - 100, eYCoord - 200);
if(sticker == null || !sticker.contains(document.getElementById(id)) || footer.length != 1){
return true;
}
else{
//it is sticker button and it is moved up (footer does not overlap)
return (footer[0].getBoundingClientRect().top >= sticker.getBoundingClientRect().bottom)
}
Copy link
Member Author

@jtnord jtnord Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if needed we can still resurrect the JS code in native selenium code to compute the bounds / offset and handle the breadcrumbs.

@jtnord jtnord force-pushed the selenium-bump branch 2 times, most recently from a54437c to 208bfbc Compare August 19, 2025 10:02
@basil
Copy link
Member

basil commented Aug 19, 2025

Seems simpler to use e.g.

executor.executeScript("arguments[0].scrollIntoView({block:'center', inline:'nearest'});", element);

which will automatically place it in the middle of the viewport without the need for advanced numerical calculations. In any case I don't think the scroller is at fault, as I have tried a number of scroller implementations and none of them affect the result. Rather, I think the problem is that we are trying to click on the wrong element.

@jtnord
Copy link
Member Author

jtnord commented Aug 20, 2025

Seems simpler to use e.g.

simpler but see https://github.com/jenkinsci/acceptance-test-harness/pull/2140/files#r2287417572 as I believe the javascript scroll is async and we can return whilst still scrolling.

@jtnord jtnord force-pushed the selenium-bump branch 3 times, most recently from 6c9847d to c036760 Compare August 21, 2025 13:27
jtnord and others added 3 commits August 21, 2025 16:50
Observed issues when setiing up matrix auth iwithout the custom scroller
that adding a second user to the table would not always work as the
button was not clickable as the dialog was still in the process of being dismissed.

After this change the flake was no longer observed.
(cherry picked from commit 4578196)
jtnord added 4 commits August 21, 2025 16:55
Remove custom JS to handle scrolling and let selenium do its thing.

Selenium hadnles scrolling elements nativly before clicking / sending
text etc as part of the WebDriver spec.

https://www.w3.org/TR/webdriver2/#element-click
> The Element Click command scrolls into view the element if it is not already pointer-interactable, and clicks its in-view center point.
the timeouts where added in the driver
Comment on lines 172 to 173
firefoxOptions.setImplicitWaitTimeout(Duration.ofSeconds(IMPLICIT_WAIT_TIMEOUT));
firefoxOptions.setPageLoadTimeout(Duration.ofSeconds(PAGE_LOAD_TIMEOUT));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not needed, but noticed in the exceptions the driver had 0 as the page load timeout. just trying this to rule anything out.

@@ -203,6 +210,22 @@ private ChromeOptions buildChromeOptions(TestName testName) throws IOException {
return chromeOptions;
}

private SafariOptions buildSafariOptions(TestName testName) throws IOException {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

untested, I have no mac.
noticed that we don't set any custom things for safari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade Selenium from 4.34 to 4.35
2 participants