2

I have been looking for a way to control the mouse wheel to simulate zooming actions for a UI test to run on Selenium headless browser. This is to carry out tests on webGL images (not available through DOM, only the canvas is available) displayed in a web browser.

So far I have been able to control the mouse wheel using pynput which works fine when I run the test on my PC in non headless browser but doesn't do anything when run in headless mode. My understanding is that the mouse wheel control is done via positioning on the screen which when it is used in headless mode doesn't exist. When the test is run, the event is actually triggered on my PC screen as opposed to in the headless browser.

Looking at the [ActionChains] (https://seleniumhq.github.io/selenium/docs/api/py/_modules/selenium/webdriver/common/action_chains.html#ActionChains.click) class which works fine for click, drag and drop, etc. in headless mode, it seems to be using the w3c UI events. I have tried to change the click() function to use button '4' (allegedly mouse wheel) instead of '0' to see if that works but I get an error message saying button '4' is invalid.

I am now at the limit of my knowledge in python/events/selenium and not seeing anyone having done this before makes me wonder if it's even possible.

Any help/tips or solutions for this would be greatly appreciated.

Thanks, Sylvain

Sylvain
  • 43
  • 8
  • this looks like a similar issue: https://stackoverflow.com/questions/47274852/mouse-scroll-wheel-with-selenium-webdriver-on-element-without-scrollbar – James Kent Dec 05 '18 at 14:40
  • Thanks James, that example worked after a bit of adjustments. Can't believe I didn't come across it after the tons of posts I went through!! At least it's now working! – Sylvain Dec 05 '18 at 16:37

0 Answers0