Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium: SVG element embedded into Object tag is not been identified by Selenium IDE or xPath?
    primarykey
    data
    text
    <p>I have an html segment like this</p> <pre><code>&lt;div id="imageholder&gt; &lt;object data="1.svg" width="100%" height="100%" type="image/svg+xml"&gt; &lt;/object&gt; &lt;/div&gt;. </code></pre> <p>When i see the inspect element in Firefox/firebug i can't see the SVG file structure, but in Chrome i am able to see the svg file structure like below:</p> <pre><code>&lt;div id="imageholder&gt; &lt;object data="1.svg" width="100%" height="100%" type="image/svg+xml"&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-dasharray="none" shape-rendering="auto" font-family="'Dialog'" width="4800"&gt; &lt;desc&gt;widthmm=90.48768097536195 heightmm=49.38127063754128&lt;/desc&gt; &lt;g&gt; &lt;g&gt;....&lt;/g&gt; &lt;/g&gt; </code></pre> <p>However, i am not able to locate svg tag or any g element through X-path. I tried with</p> <pre><code>//div[contains(@id='imageholder')] </code></pre> <p>then i get the element correctly.</p> <pre><code>//div[contains(@id='imageholder')/object] </code></pre> <p>also returns element correctly. But </p> <pre><code>//div[contains(@id='imageholder')/object/svg] </code></pre> <p>fails. </p> <p>My requirement is: I need to click on several g elements of SVG image, but i am not able to reach it. Your help will be appreciated. Thanks</p> <p>Some more details added on:[Dec 8,2011]</p> <pre><code>driver.findElement(By.xpath("//div[@id='imageholder']/object"));//This worked correctly driver.findElement(By.xpath("//div[@id='imageholder']/object/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']"));//did not work </code></pre> <p>I also tried all the possible combination <a href="https://stackoverflow.com/questions/529556/xpath-find-elements-by-attribute-namespace">XPath - Find elements by attribute namespace</a> given on this link but could not succeed. Thanks</p> <p>For more details, please find the sample code.</p> <h1>Sample.html</h1> <pre><code>&lt;html&gt;&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9;chrome=IE8"&gt; &lt;body&gt; &lt;div id="imageholder"&gt;&lt;object data="1.svg" width="100%" height="100%" type="image/svg+xml"&gt;&lt;/object&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <h1>1.svg</h1> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'&gt; &lt;svg stroke-dasharray="none" shape-rendering="auto" xmlns="http://www.w3.org/2000/svg" font-family="&amp;apos;Dialog&amp;apos;" width="4800" text-rendering="auto" fill-opacity="1" contentScriptType="text/ecmascript" color-interpolation="auto" color-rendering="auto" preserveAspectRatio="xMidYMid meet" font-size="12" viewBox="0 0 4800 2619" fill="black" xmlns:xlink="http://www.w3.org/1999/xlink" stroke="black" image-rendering="auto" stroke-miterlimit="10" zoomAndPan="magnify" version="1.0" stroke-linecap="square" stroke-linejoin="miter" contentStyleType="text/css" font-style="normal" height="2619" stroke-width="1" stroke-dashoffset="0" font-weight="normal" stroke-opacity="1" &gt; &lt;g style="fill-opacity:0.7; stroke:black; stroke-width:0.1cm;"&gt; &lt;circle cx="6cm" cy="2cm" r="100" style="fill:red;" transform="translate(0,50)"/&gt; &lt;circle cx="6cm" cy="2cm" r="100" style="fill:blue;" transform="translate(70,150)"/&gt; &lt;circle cx="6cm" cy="2cm" r="100" style="fill:green;" transform="translate(-70,150)"/&gt; &lt;/g&gt; &lt;/svg&gt; </code></pre> <p>Please click on sample.html once you save the files.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload