Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9283421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:37:40+00:00 2026-06-18T18:37:40+00:00

I have an SVG object with a few circle and rectangle elements. Using webdriver,

  • 0

I have an SVG object with a few circle and rectangle elements. Using webdriver, I can click on the main svg object, but not any of the elements within it. The problem only seems to be with clicking (or any mouse interaction), as I can use getAttribute() to return the value(s) of width, ID, x/y, text, etc, for anything under it.

Here is an example of the HTML:

    <div id="canvas">
        <svg height="840" version="1.1" width="757" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;">
            <image x="0" y="0" width="757" height="840" preserveAspectRatio="none">
            <circle cx="272.34" cy="132.14">
            <rect x="241.47" y="139.23">
            <text style="text-anchor: middle; x="272.47" y="144.11">
        </svg>
    </div>

And an example of WebDriver trying to right click a rectangle element (and failing):

    WebElement mapObject = driver.findElement(By.xpath("//*[name()='svg']/*[name()='rect']"));
    Actions builder = new Actions(driver);
    builder.contextClick(mapObject).perform();

But this works and returns a value:

    driver.findElement(By.xpath("//*[name()='svg']/*[name()='rect']")).getAttribute("x");    

When WebDriver errors, it’s usually this:

    org.openqa.selenium.WebDriverException: '[JavaScript Error: "a.scrollIntoView is not a function" {file: "file:///var/folders/sm/jngvd6s97ldb916b7h25d57r0000gn/T/anonymous490577185394048506webdriver-profile/extensions/fxdriver@googlecode.com/components/synthetic_mouse.js" line: 8544}]' when calling method: [wdIMouse::move]

I’ve spent some time researching this and it seems to be a somewhat common issue with Selenium and SVGs, however I’m wondering if there is a workaround. The only solutions I’ve found are interacting with the SVG itself, which I can already do.

I’m using Selenium 2.28 (and tried 2.29) w/ Java + Firefox 17.

Any ideas greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:37:41+00:00Added an answer on June 18, 2026 at 6:37 pm

    For anyone interested, I solved this in the following ways:

    1) I was originally testing this on OSX with Firefox 17 and Selenium 2.28/29, but figured out it only works (at least for me) on Windows with Firefox 18 and Selenium 2.29

    2) interacting with SVGs with the standard:

    driver.findElement(By.xpath(YOUR XPATH)).click();
    

    doesn’t work. You need to use Actions.

    3) to interact with SVG objects, the following XPath works:

    "/*[name()='svg']/*[name()='SVG OBJECT']";
    

    The SVG object being anything under the SVG element (e.g. circle, rect, text, etc).

    An example of clicking an SVG object:

    WebElement svgObject = driver.findElement(By.xpath(YOUR XPATH));
    Actions builder = new Actions(driver);
    builder.click(svgObject).build().perform();
    

    Note: you need to call the path inside the click() function; using:

    moveToElement(YOUR XPATH).click().build().perform();
    

    doesn’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody have any experience with the Raphael.js SVG library? I'm using Raphael.js to
As the title states, I have a svg image, but I am not able
right now I have a group of svg elements (circle, rect, path, etc.).The actual
I have this svg: <circle cx=50 cy=100 r=50 stroke-width=0 fill=orange/> <polygon points=0,100, 50,50 100,100
I plan to have some (a lot of) objects inside of svg-object that will
I have an SVG file within an object tag displaying in a table cell,and
I have a composite svg object with shading and highlights. Is there a way
I have an SVG (html): <div> <svg xmlns=http://www.w3.org/2000/svg version=1.1> <g id=radius-selector> <!-- Circle -->
I have an SVG file embedded into an HTML document inside . I can
Secondly, I have an SVG form transform in different path using raphaeljs lib. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.