-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Wallaby does not click or throw an error for buttons that are not visible in the window #501
Comments
Hi @cysiegel Visible doesn't mean visible in the viewport, it means visible on the page, so Most WebDriver implementations when told to interact with an element that is visible but off-the-screen are implicitly performing a scroll to that location before interacting. Sometimes that is implemented naively and can cause the interaction to fail. For example, I had a similar experience to yours with Chrome and pages that have a "sticky" floating menu visible on top of the window even after scrolling down. Chromedriver was sometimes scrolling to the element so that it was in the viewport but underneath the menu. Scrolling with JavaScript is a correct work-around IMO. |
@michallepicki thanks for your quick response If I understand you correctly - we can't throw just an error when trying to interact with an element not in the viewport because the behavior varies between drivers and the DOM |
@cysiegel More or less, yes. We could add an additional check that could be used together with |
@michallepicki Thanks for your help!!!! |
They use a slightly different implementation now, I have not tested it: https://github.com/webdriverio/webdriverio/blob/5cceaa8e0b6b5fdc870a777e418fcd9f434f31f5/packages/webdriverio/src/scripts/isElementInViewport.js There is some nuance here with elements fully vs only partially visible in the viewport, maybe that's why they changed it. |
FYI, I used a workaround in my case by scrolling 1 in y axis with use Wallaby.Feature
import Wallaby.Query
session
|> # omit some operations
|> touch_scroll(link("Paddings"), 0, 1)
|> click(link("Paddings")) |
Notice that there is no |
I'm trying to click on a button that exists in the HTML however is no longer visible to a human user because the window scrolled down from an earlier part of the test
When calling the function
click
on the element no error is thrown - even though the DOM element never gets clicked on (assert_has
also does not throw an error)It seems strange that the
click
function does not throw an error because the element exists in the HTML - while at the same time fails to click on the element because its not in the visible windowWhile I solved my specific problem by scrolling up - (
execute_script(session, "window.scrollTo(0, 0);")
) - it would be nice to either be able to click elements that are visible in the HTML and if its not clickable then for an error to be thrown(BTW it would be a nice feature to have wallaby scroll functions without having to use javascript)
.
The text was updated successfully, but these errors were encountered: