【问题标题】:Katalon Studio not finding svg tag to create objectKatalon Studio 找不到 svg 标签来创建对象
【发布时间】:2018-05-25 21:24:47
【问题描述】:

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

【问题讨论】:

  • 你需要找到一个输入类型字段来发送文件。
  • 我不确定你的意思
  • 请在页面源中搜索输入类型字段。您应该将文件传递给该字段。

标签: html testing svg ui-testing katalon-studio


【解决方案1】:

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 http://www.w3.org/2000/svg的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"]

拜托,看看有没有帮助。

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
  • 使用从外部链接获取的基本代码部分编辑了答案。
猜你喜欢
  • 2018-08-08
  • 2021-11-10
  • 1970-01-01
  • 1970-01-01
  • 2018-09-20
  • 2014-07-25
  • 2018-09-30
  • 2019-01-02
相关资源
最近更新 更多