c# - Capture contentDocument for svg object in selenium -
i'm trying automate test svg images rendered in web application.
the html looks like-
<object class="svgcanvas" type="image/svg+xml" data="test.svg"><h4>error loading svg file</h4> #document <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -webkit-user-drag: none; -webkit-tap- highlight-color: rgba(0, 0, 0, 0);" viewbox="0 0 1188 840" xml:space="preserve"> <rect x="0" y="0" width="1188" height="840" style="stroke:none; fill:white"/> <circle cx="20" cy="830" r="0.144857" style="stroke:#e50033; stroke- width:0.339429"/> <g id="xmp_1" style="stroke:#000000; stroke-width:0.339429"> <path d="m554 401l641 401" style="stroke:#0000ff; stroke-dasharray: 3.5640 3.5640 3.5640 3.5640"/> </g> </object>
i tried svg object using below code svgelement throws following error:
'((openqa.selenium.remote.remotewebelement)svgelement).displayed' threw exception of type 'openqa.selenium.staleelementreferenceexception'
iwebelement objecttag = _webdriver.findelement(by.cssselector("object.svgcanvas")); ijavascriptexecutor js = (ijavascriptexecutor)_webdriver; string findingsvg = "return arguments[0].contentdocument;"; var svgelement = js.executescript(findingsvg, objecttag);
so, there way test page have svg embedded in object tag?
any appreciated.
your code tries contentdocument
<object>
tag returns document object frame, it's not supposed work.
the <object>
tag inside <frame>
try switching content in frame contains <svg>
, find element:
_webdriver.switchto().defaultcontent(); _webdriver.switchto().frame("yourframename"); iwebelement svgelementinsideframe = _webdriver.findelement(by.tagname("svg"));
Comments
Post a Comment