Webアプリケーションでレンダリングされるsvgイメージのテストを自動化しようとしています。コンテンツをキャプチャしてsvgオブジェクトをセレンに入れます
htmlのは、私は以下のコードを使用して、SVGオブジェクトを取得しようとしましたが、svgElementは、次のエラースロー
<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>
like-になりますので、
'((OpenQA.Selenium.Remote.RemoteWebElement)svgElement).Displayed' threw an 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);
を、方法がありますオブジェクトタグにSVGが埋め込まれているページをテストするには?
ご迷惑をおかけして申し訳ございません。
古い要素は通常、後にあなたが要素を発見し、呼び出す前にあることを意味そのオブジェクトがページをリロード/変更したときのアクション。ページがロードされ、すべての要求が完了していることを確認します。 – lauda
SVGを操作しようとする前に、SVGとメインDOMがロードされていることを確認する方法が必要です。 Google(またはスタートページ):セレンは、JavaScriptがロードされるのを待ちます – MikeJRamsey56
'isDisplayed()'の行に例外がスローされますか? '