添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account cy.click on a SVG or an element containing SVG throws Illegal Invocation error in Cypress 3.0.3 #2258 cy.click on a SVG or an element containing SVG throws Illegal Invocation error in Cypress 3.0.3 #2258 greglds opened this issue Aug 2, 2018 · 1 comment · Fixed by #2246

Current behavior:

Since update to 3.0.3, cy.get( "element containing SVG" ).click() throws an error:
CypressError: Timed out retrying: Illegal invocation

Available workaround is to use { force: true } (doesn't work when clicking on SVG directly)

Desired behavior:

The same behavior as the other elements (not containing SVG): a simple click.

Steps to reproduce:

given this html body:

<span id="test-text" href="#"> </span> <span id="test-svg" href="#"> <svg height="100" width="100"> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /> </span> </body>

and this spec:

describe("test click on svg", () => {
	beforeEach( () => {
		cy.visit('/');
	it( "clicks a span containing text", () => {
		cy.get("#test-text").click();
	it( "clicks a span containing SVG", () => {
		cy.get("#test-svg").click();

I obtain this result:

My current workaround:

Cypress.Commands.overwrite("click", (originalFn, subject, options = {}) => { 
    if( subject[ 0 ].getElementsByTagName('svg').length ) { 
        Object.assign( options, { force: true } ); 
    return originalFn(subject, options); 

Versions

Cypress 3.0.3, Windows 7, Chrome v 67.0.3396.99

On a side note, Cypress is great !

This has already been fixed in a PR and will go out in the next patch release... approximately less than 24 hours.

#2246