html - Katalon Studio 找不到用于创建对象的 svg 标签

标签 html testing svg ui-testing katalon-studio

我正在尝试创建一个用于拖放的对象,但我没有为嵌套在 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/

相关文章:

html - 如何定位文本框?

ruby - HTML5 视频和 Rails 3

c++ - 为什么字体中的图标上方有很多空格?

haskell - 使用 libcairo 和 Haskell 的多页 SVG

javascript - 如何将 Selenium 用于桌面应用程序?

svg - 如何判断 SVG 何时完成渲染

javascript - 如何在 IE8 中禁用 ondblclick?

c++ - 通过 Web 服务器远程运行 C++ 程序(Visual Studio 应用程序)

python - 在使用 Django TestCase 进行测试时如何检查 ValidationError 异常?

Sharepoint 测试后发布