Robot Framework issue: Element not clickable in headless mode

I’m having trouble with my Robot Framework test. It works fine in normal mode, but when I switch to headless, it can’t click an element. Here’s a simplified version of my code:

Find Element    id=email-input
Type Text    id=email-input
Find Element    xpath=//button[@aria-label='Submit']
Set Focus    xpath=//input[@type='checkbox' and @name='select-row']
Find Element    xpath=//input[@type='checkbox' and @name='select-row']

When I run this in headless mode, I get an error saying the element isn’t clickable. It’s something about the element being intercepted by another div. Has anyone else run into this? How can I fix it so it works in headless mode too?

I’ve encountered this issue before, and it can be frustrating. One thing that worked for me was using the ‘Wait Until Element Is Visible’ keyword before attempting to interact with the element. This ensures the element is fully loaded and visible before you try to click it.

Another trick I found helpful was to use Execute JavaScript to click the element instead of the standard click method. Sometimes this bypasses issues with overlays or other elements intercepting the click.

If those don’t work, you might want to try increasing the timeout for element location or adding a small delay before interacting with elements. Headless mode can sometimes be a bit slower to render elements, so giving it a little extra time can make a difference.

Lastly, double-check that your viewport size in headless mode matches what you’re using in headed mode. I’ve seen cases where elements were off-screen in headless due to different viewport dimensions.

I’ve faced similar issues with headless mode. In my experience, the problem often lies in the element not being fully loaded or visible when running in headless mode. A brief pause before interacting can help, and using JavaScript to trigger the click sometimes yields better results than relying solely on Selenium’s click function. Additionally, adjusting the viewport size to mimic normal mode and scrolling the target element into view can resolve visibility problems. Overlays or popups may also interfere unexpectedly, so it’s worth checking for those conditions.

hey, i’ve had this prob too. try using ‘Execute JavaScript’ to click the element. sometimes it gets around those annoying overlay issues. also, make sure ur viewport size is set right in headless mode. elements can be off-screen if its different from normal mode. good luck!