在Katalon Studio中,如何在没有标签或名称对象属性的情况下点按iOS应用程序的元素 [英] In Katalon Studio how to tap an iOS app’s element when it doesn’t have either label or name object properties

查看:197
本文介绍了在Katalon Studio中,如何在没有标签或名称对象属性的情况下点按iOS应用程序的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

KS 6.3.2可以点击包含标签或名称对象属性的元素.但是,我正在测试的应用程序具有一个元素,该元素是一个按钮,并且不包含标签,名称或任何文本.此外,该元素的xpath是动态的.

以下是从2种不同设备捕获的应用程序相同元素的对象属性的快照:

以下是所选定位器"的值:

我的页面1:

//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘160.0’ and @x = ‘664.0’ and @y = ‘1628.0’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘160.0’ and @x = ‘664.0’ and @y = ‘1628.0’])]

我的页面2:

//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘142.0’ and @x = ‘604.0’ and @y = ‘1238.0’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘142.0’ and @x = ‘604.0’ and @y = ‘1238.0’])]

如上所示,以下对象属性值不是静态的: 宽度 X ÿ xpath

但是,xpath的开始"和结束"值或多或少是恒定的. xpath常数的起始值是://XCUIElementTypeApplication/XCUIElementTypeWindow 1 xpath常数结尾-值为:/XCUIElementTypeTabBar 1 /XCUIElementTypeButton [6]

我已经尝试过使用xpath的开头和结尾值,但是没有用.因此,任何建议将不胜感激.它们如下:

xpath以选定的定位符值结尾:

/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’])]

xpath以选定的定位符值开头:

//XCUIElementTypeApplication/XCUIElementTypeWindow[1][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’])]

DOM树代码段:

解决方案

经过一些挖掘和研究,我发现了以下解决问题的方法:

1)在appium-desktop的帮助下,我得到了[x,y] 元素的坐标.然后在KS中,我使用了称为 tapAtPosition(x,y)以点击图标.但是,这不是最终的 我最终使用的方式.

2)我最终使用KS spy为该元素创建了一个相对xpath 移动的.这是我对该元素的最终相对xpath: //*//XCUIElementTypeButton [6]

KS 6.3.2 is able to tap on an element that contains label or name object properties. However, the application that I have under test has an element which is a button and does not contain either label or name or any text. Furthermore, the xpath of that element is dynamic.

The following are the snapshots of the Object’s properties of the same element of an application captured from 2 different devices:

The following is the Selected Locator’s value:

My Page 1:

//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘160.0’ and @x = ‘664.0’ and @y = ‘1628.0’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘160.0’ and @x = ‘664.0’ and @y = ‘1628.0’])]

My Page 2:

//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘142.0’ and @x = ‘604.0’ and @y = ‘1238.0’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘142.0’ and @x = ‘604.0’ and @y = ‘1238.0’])]

As you can see above that the following object properties values are not static: width x y xpath

However, the xpath’s starts-with and ends-with values are more or less constant. xpath constant starts-with value is: //XCUIElementTypeApplication/XCUIElementTypeWindow1 xpath constant ends-with value is: /XCUIElementTypeTabBar1/XCUIElementTypeButton[6]

I have tried with xpath starts-with and ends-with values but it didn’t work. So any suggestion will be highly appreciated. They are as follows:

xpath ends-with selected locators value:

/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’])]

xpath starts-with selected locators value:

//XCUIElementTypeApplication/XCUIElementTypeWindow[1][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’])]

DOM tree snippet:

解决方案

After some digging and research, I found the following methods to solve my problem:

1) With the help of appium-desktop, I was able to get the (x,y) co-ordinates of the element. Then in KS, I used the method called tapAtPosition(x,y) to tap at the icon. However, this is not the final way I ended up using.

2) I ended up creating a relative xpath for the element using KS spy mobile. This was my final relative xpath for the element: //*/XCUIElementTypeButton[6]

这篇关于在Katalon Studio中,如何在没有标签或名称对象属性的情况下点按iOS应用程序的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆