Element is not clickable at point (Laravel Dusk)
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Ran into an interesting issue today when filling in a form with Laravel Dusk. It ran locally but then failed selecting an input when running on CircleCI. It was quite a long form on the page, so by the sounds of the issue the form element I wanted to select was out of the viewport and for that reason Chrome couldn't interact with it.
I actually came across two solutions to the issue - the first is to instruct Chrome to create a larger window so that your entire form will fit in the viewport, and the second is to manually execute JavaScript that will scroll the viewport for you. The choice is yours and it comes down to whether you'd use an unrealistic user viewport or manually scroll the page.
Changing Chrome Driver's Viewport
In your tests/DuskTestCase.php
file you have the ability to control the arguments that instantiate the Chrome Driver. You can use the --window-size
argument to make the size of the window large enough to fit your biggest pages.
Manually Scrolling The Viewport
This option is a little more labour intensive as you'll have to pop it in your tests wherever it's required. What's more is that it breaks the assertion train of the test so you need to do it all on a separate line.
Of course you'll need to adjust the second argument there depending on how far down the page you intend to scroll. Let me show you an example of how you'll need to break the assertion chain in order to execute this script.