title: Selenium WebDriver: clicking on elements within an SVG using XPath
body: <p>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.</p>
  
  <p>Here is an example of the HTML:</p>
  
  <pre><code>    &lt;div id="canvas"&gt;
          &lt;svg height="840" version="1.1" width="757" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;"&gt;
              &lt;image x="0" y="0" width="757" height="840" preserveAspectRatio="none"&gt;
              &lt;circle cx="272.34" cy="132.14"&gt;
              &lt;rect x="241.47" y="139.23"&gt;
              &lt;text style="text-anchor: middle; x="272.47" y="144.11"&gt;
          &lt;/svg&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>And an example of WebDriver trying to right click a rectangle element (and failing):</p>
  
  <pre><code>    WebElement mapObject = driver.findElement(By.xpath("//*[name()='svg']/*[name()='rect']"));
      Actions builder = new Actions(driver);
      builder.contextClick(mapObject).perform();
  </code></pre>
  
  <p>But this works and returns a value:</p>
  
  <pre><code>    driver.findElement(By.xpath("//*[name()='svg']/*[name()='rect']")).getAttribute("x");    
  </code></pre>
  
  <p>When WebDriver errors, it's usually this:</p>
  
  <pre><code>    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]
  </code></pre>
  
  <p>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.</p>
  
  <p>I'm using Selenium 2.28 (and tried 2.29) w/ Java + Firefox 17.</p>
  
  <p>Any ideas greatly appreciated.</p>