1

I get element not visible exception when I use this xpath to click on SVG element. I was able to click on it if I use Actions class but firefox 48 gecko driver does not support Actions class yet.

I tried this and it did not work: (Element not visible exception)

driver.findElement(By.xpath("//*[name()='svg']/*[name()='line' and @x1='195.5']")).click();

I also tried this and it did not work: (Element not visible exception)

    WebElment element = driver.findElement(By.xpath("//*[name()='svg']/*[name()='line' and @x1='195.5']"))
    JavascriptExecutor js = (JavascriptExecutor)driver;
    js.executeScript("arguments[0].click();", element);

I tried this and it worked only in chrome but not in Firefox 48 gecko driver:

    WebElment element = driver.findElement(By.xpath("//*[name()='svg']/*[name()='line' and @x1='195.5']"))
    Actions action = new Actions(driver);
    action.moveToElement(element).click().build().perform();

Is there any other way to click on this SVG element?

Below is the html code:

<div id="figed_canvas_axis_Figed_0" style="width:369px;height:369px;">
  <svg id="Figed_0_axis" viewBox="0 0 369 369">
    <line x1="195.5" y1="182.5" x2="195.5" y2="188.5" style="stroke:#808080;stroke-width:1"></line>
SOAlgorithm
  • 407
  • 1
  • 5
  • 15
  • Can be useful: http://stackoverflow.com/questions/14592213/selenium-webdriver-clicking-on-elements-within-an-svg-using-xpath – Ranjith's Sep 02 '16 at 13:42

0 Answers0