Python webdriver execute_script (JQuery) on SVG elements hangs

61 views
Skip to first unread message

Oscar Rovira

unread,
Jan 20, 2018, 8:23:05 AM1/20/18
to Selenium Users
Hi there!

I'm trying to validate a SVG plot by interacting (triggering events) over some nodes in it. The way I'm implementing the interaction is through the use of execute_script running a piece of JQuery (selector + trigger(event)). This was working on previous versions of Selenium, now, with selenium==3.7.0, this doesn't work anymore.

A sample code of the implementation would be:

>>> from selenium import webdriver
>>> wd = webdriver.Firefox()
>>> s = '$(\'[data-node-type="leaf_node"][transform="translate(236.66666666666663 459)"]\').trigger('mouseenter')'
>>> wd.execute_script(s)
# here the execution hangs, nothing is returned and I only can kill the process


In the code above, [data-node-type="leaf_node"][transform="translate(236.66666666666663 459)"], is a g node in the SVG which I'm trying to select using JQuery. As I said this was working in previous versions of Selenium.
However, a similar interaction on a regular HTML element works as expected.

Does anyone know what is going on or have a workaround?

Thanks"

David

unread,
Jan 20, 2018, 2:02:45 PM1/20/18
to Selenium Users
If you execute the JQuery code from the Firefox browser console, does it work? Just to narrow down if issue with the driver or Firefox version itself.

Also, are you sure you have the quoting escape syntax right? If I'm not mistaken, I would think you want to quote escape the mouse enter as \'mouseenter\' or use double quotes since mouseenter likely isn't a python variable here but rather a JS event name.

Oscar Rovira

unread,
Feb 1, 2018, 4:44:36 AM2/1/18
to Selenium Users
Hi David, 
Thanks for the reply.
Actually it doesn't work in the Firefox console, this is a legacy viz library that overwrites some of the standard mouse events, there are a couple of them that work fine when triggered with the execute_script, but the others, like the mouseover or mouseenter equivalent, that simply doesn't work. The funny thing is that the real interaction with the mouse pointer over the screen works. I will have to debug deeper in the code to actually know which DOM/SVG event is being triggered at the end. Maybe is an issue with the firefox version, it used to work with previous versions, now I'm running 56.0 for these tests.

Regarding the sample code, you're right, I had a typo when wrote it here in the email editor.

Thx.
Reply all
Reply to author
Forward
0 new messages