简体   繁体   English

如何使用Sikuli + Java根据与其相邻的文本选择单选按钮?

[英]How to select a radio button based on the text adjacent to it using Sikuli + Java?

How to select a radio button based on the text adjacent to it using Sikuli + Java ? 如何使用Sikuli + Java根据与其相邻的文本选择单选按钮?

There are 3 radio buttons(with some text adjacent to them) present on the screen. 屏幕上显示3个单选按钮(旁边有一些文本)。 Sikuli is always clicking on the second one. Sikuli总是单击第二个。 How can I click the other radio buttons? 如何单击其他单选按钮?

The screen is as shown below. 屏幕如下图所示。 Treat that 'O' as a radio button and provide any solution for it. 将“ O”视为单选按钮,并为其提供任何解决方案。 (I cant upload the screenshot hence I shown it as below) (我无法上传屏幕截图,因此如下所示)

  • O abcd O abcd
  • O efgh 奥夫
  • O asdf 奥夫

Now how can I click on the 1st or the 3rd 'O'(Radio button) 现在如何单击第一个或第三个“ O”(单选按钮)

to give u an exact solution, it would be helpful to know if you are using sikuli-java-api or sikuliX-api. 为了给您一个确切的解决方案,知道您使用的是sikuli-java-api还是sikuliX-api将很有帮助。 In any case the logic behind both would be same, that is- 无论如何,两者背后的逻辑都是相同的,即-

  • first search for the image/screenshot of the text u need the radio button to be selected for and map it to Screen/Region, call this say TextRegion (depending on ur api again) 首先搜索文本的图像/屏幕截图,您需要选择单选按钮并将其映射到屏幕/区域,称此为TextRegion(再次取决于ur api)
  • select the region to the left of ur TextRegion and map it to another Screen/Region, call this say LeftRegion 选择ur TextRegion左侧的区域并将其映射到另一个Screen / Region,称此为LeftRegion
  • Now within LeftRegion, search for a subRegion to match to ur image of radio button. 现在在LeftRegion中,搜索子区域以与您的单选按钮图像匹配。 u can now select that subRegion and name it SelectedRegion 您现在可以选择该子区域并将其命名为SelectedRegion
  • click on SelectedRegion 点击SelectedRegion

You can create a generic method for this process, passing the image of the text for which u need the radio button to be selected and the image of the radio button as parameters. 您可以为此过程创建通用方法,将需要选择单选按钮的文本图像和单选按钮的图像作为参数传递。 Also, you can use highlight to identify the subRegions that you have created. 另外,您可以使用突出显示来标识您创建的子区域。 It proves useful in understanding where you might've gone wrong. 事实证明,它有助于您理解可能出了问题的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM