html - Katalon Studio 找不到 svg 标签来创建对象
问题描述
我正在尝试创建一个用于拖放的对象,但我没有为嵌套在 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 。
对于此处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-uri http://www.w3.org/2000/svgXPath
的 svg 节点:
//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"]
最后,您可以SVG
通过以下XPath
表达式选择文本节点:
//div[@id="container"]/div/*[local-name()="svg"]/*[local-name()="text" and @class="highcharts-title"]
请,看看它是否有帮助。
推荐阅读
- python - 为什么 print("\5") 在 python 中输出一个新行
- javascript - 我可以得到像11.0.9600这样的IE版本号和更新号吗?
- ruby-on-rails - 在rails上获取数据
- c# - 如何禁用未实现异常的自动生成?
- android - 有没有办法将分隔线与另一个视图对齐,但使其比另一个视图“更长”?
- javascript - 鼠标垫在 JavaScript 中触发了太多的“滚轮”事件
- python - 如何在python中打开txt文件的链接?
- c# - 在 n 层 WEB API 上使用没有 app.config 的实体框架连接到 Oracle
- node.js - 为什么对象值没有变化?
- java - 我们如何创建不同引用的 n 个节点?