Closed bennypi closed 1 year ago
@bennypi, thank you for creating this issue. We will troubleshoot it as soon as we can.
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template
label.
If the issue is a question, add the I-question
label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted
label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-*
label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer
label.
Thank you!
This is probably caused by Bootstrap 5 setting scroll-behavior: smooth
on the html element of the page. Selenium then can't automatically scroll to the element any longer when trying to click something outside the view window. We had a bunch of tests failing because of this as well after upgrading from Bootstrap 4 to 5. You can fix this in several ways:
// Scroll to element
driver.executeScript("arguments[0].scrollIntoView();", checkbox);
// pause for 1 second to wait until scroll is completed
await wait(1000);
scroll-behavior: auto !important;
on the html element (i.e. in CSS or using the style attribute). You could also only do this when running the tests (e.g. when in the test environment if for example you are using Ruby on Rails).$enable-smooth-scroll: false;
Solutions from https://github.com/symfony/panther/issues/502 and https://github.com/SeleniumHQ/selenium/issues/8973#issuecomment-786611503
While the above solutions work (for me), I think it would be better if Selenium supports smooth scrolling out-of-the-box (also when automatically scrolling when clicking something outside the view window). This is also suggested by https://github.com/symfony/panther/issues/502#issuecomment-1212324362.
There were also several Selenium issues in the past about this, which looks like they are caused by the same issue:
@titusfortner @diemol what do you think?
Hope this helps people running into this issue as well!
If you are using rails, you can find here the way to disable the bootstrap scroll-behavior only for the test environment:
http://fullstacktutorials.blogspot.com/2023/03/selenium-doesnt-work-with-bootstrap-5.html
I suspect Titus's comment on the issues listed in https://github.com/SeleniumHQ/selenium/issues/11136#issuecomment-1370803713 is still valid for this issue. But I would like @titusfortner to help confirm the same! Thank you!
I'm not sure why it would work with Selenium 3 and not with Selenium 4. I'm not sure what Selenium can or should do about it.
I think it would be better if Selenium supports smooth scrolling out-of-the-box
I think this needs to be managed by browser vendor implementations, and might need to be discussed in w3c.
Hi, @bennypi. This issue has been determined to require a change to the WebDriver W3C Specification for Selenium to be able to support it.
Please create an issue with the WebDriver project.
Feel free to comment the issues that you raise back in this issue. Thank you.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
What happened?
Selenium can not click on a button altough the button is visible. In a demo project, spring boot 2.7, selenium 4.5.0 and testcontainers 1.17.5 is used. The application consists of a simple HTML page that shows text that the user can send from an input field inside of a form. There is a unit test that uses SpringBootTest, testcontainers and selenium to check this mechanism. The expected outcome of the test is that the data inserted in the input field and submitted with the button is present on the new page, but the test fails with a exception, please see the log output below.
From my testing, this error does no longer appear when bootstrap css is not included, or when simple divs, headers and paragraphs are used instead of details and summaries. The error is also not present when selenium is downgraded to 3.141.59. The error also seems to disappear in case the page is "short" enough. For the demo, I added a margin so that the page can be scrolled on a FullHD display.
How can we reproduce the issue?
Relevant log output
Operating System
Linux Mint 21
Selenium version
Java 4.5.0
What are the browser(s) and version(s) where you see this issue?
selenium/standalone-chrome:4.5.0
What are the browser driver(s) and version(s) where you see this issue?
selenium-chrome-driver 4.5.0
Are you using Selenium Grid?
No response