我正在尝试创建一个用于拖放的对象,但我没有为嵌套在 svg 标签内的图像创建对象。 Katalon 是否能够找到 svg 标签?
我可以在我的网络应用程序中找到超过图像,但当它嵌套在 svg 标签中时却找不到。
<svg class="enyo-svg image" id="application_mainView_FileViewerPanel_control16_projectView1_Frame"
preserveAspectRatio="none" version="1.1"xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" style="width: 532.7px; height: 355.13px;">
<image id="application_mainView_FileViewerPanel_control16_projectView1_Image"
xlink:href="assets/images/projects/centroCivico.svg" x="0" y="0"
width="100%" height="100%" preserveAspectRatio="xMidYMid meet" style=""></image></svg>
最佳答案
github 上有这个讨论:https://github.com/kazurayam/KatalonDiscussion4977 .
对于可用的基本应用程序 here ,我们试图访问的 SVG
元素的 HTML 是
<html>
<body>
<div id="hs-component">
<div class="container">
<div id="wrap">
...
<div class="... demo">
...
<div class="chart-container">
<div id="container">
<div id="highcharts-0x1te9k-0">
<svg xmlns="http://http://www.w3.org/2000/svg" ...>
...
<text class="highcharts-title">
<tspan>Solar Employment Growth by Sector, 2010-2016</tspan>
</text>
...
</svg>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
以下 XPath
选择器不起作用:
//div[@id="container"]/div/svg
Katalon 发出警告
com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/Page_Basic line/svg_namespace-ignorant' located by 'By.xpath: //div[@id="container"]/div/svg' not found
XPath
需要是 Namespace-aware .
带有 Namespace-uri 的 svg 节点 http://www.w3.org/2000/svg可以通过以下 XPath
选择:
//div[@id="container"]/div/*[namespace-uri() = "http://www.w3.org/2000/svg" and local-name()="svg"]
但是,目标文档恰好只有一个名为“svg”的节点,因此您可以放宽谓词,省略条件 namespace-uri()="..."。以下 XPath
表达式也适用:
//div[@id="container"]/div/*[local-name()="svg"]
最后,您可以通过以下XPath
表达式选择SVG
文本节点:
//div[@id="container"]/div/*[local-name()="svg"]/*[local-name()="text" and @class="highcharts-title"]
拜托,看看它是否有帮助。
关于html - Katalon Studio 找不到用于创建对象的 svg 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50537022/