I’ve inherited some Selenium Webdriver code (Ubuntu 11.10, Xvfb + Selenium 2.19.0 & Firefox 10.0.2, because that’s the only combination I’ve been able to hit upon in the time available that actually installs.)
Note: I am not using the old Selenium 1.0 system, which most documentation seems to be focussed at.
My tests are running very slowly. Simple mouse movements are taking over half a second.
Looking at the (undocumented?!) /tmp/native_ff_events_log file, I find that each mouse operation is being divided up into smaller parts:
D14:14:37:070 cpp/webdriver-interactions/interactions_linux_mouse.cpp(307) ---------- starting mouseMoveTo: 0x7fbad37546a0---------
D14:14:37:070 cpp/webdriver-interactions/interactions_linux_mouse.cpp(328) From: (39, 169) to: (350, 86)
D14:14:37:070 cpp/webdriver-interactions/interactions_linux_mouse.cpp(329) Distance: 321 steps: 64
D14:14:37:070 cpp/webdriver-interactions/interactions_linux_mouse.cpp(339) Moving to: (39, 169)
D14:14:37:070 cpp/webdriver-interactions/interactions_linux_mouse.cpp(231) Type: motion time: 401697248
D14:14:37:080 cpp/webdriver-interactions/interactions_linux_mouse.cpp(339) Moving to: (43, 167)
D14:14:37:080 cpp/webdriver-interactions/interactions_linux_mouse.cpp(231) Type: motion time: 401697258
D14:14:37:090 cpp/webdriver-interactions/interactions_linux_mouse.cpp(339) Moving to: (48, 166)
D14:14:37:090 cpp/webdriver-interactions/interactions_linux_mouse.cpp(231) Type: motion time: 401697268
D14:14:37:100 cpp/webdriver-interactions/interactions_linux_mouse.cpp(339) Moving to: (53, 165)
D14:14:37:100 cpp/webdriver-interactions/interactions_linux_mouse.cpp(231) Type: motion time: 401697278
D14:14:37:110 cpp/webdriver-interactions/interactions_linux_mouse.cpp(339) Moving to: (58, 163)
It appears like there is some deliberate slowing down, similar to the legacy Selenium’s setMouseSpeed(pixels), which breaks up drag-and-drop operations into 10 pixel submovements.
I’m not using drag-and-drop. Also, I believe this method is no longer available to me.
I do not believe these submovements are necessary, and removing them might speed the run considerably.
Is there a way to increase the size of the mouse steps in Selenium 2’s Webdriver?
Oddthinking, looking at source code I found two values that make mouseMoveTo() so slowly:
http://code.google.com/p/selenium/source/browse/trunk/cpp/webdriver-interactions/interactions_linux_mouse.cpp?r=13310#278
http://code.google.com/p/selenium/source/browse/trunk/cpp/webdriver-interactions/interactions_linux_mouse.cpp?r=13310#270
Unfortunately, there is no way to change this values on runtime level, because are hardcoded.
When mouse needs to move from Point A to Point B, it does using a 5 pixel step with 10ms interval. One step from my testcase was taking about 1.2 seconds to do a simple click()
I recompiled the firefox extension changing stepSizeInPixels to 50 and timePerEvent to 5ms. Now my testcase is taking 18 seconds, 8 seconds less that original extension.