使用 Robot Framework 处理随机按钮

Handling with random button with Robot Framework

我正在尝试将 Robot Framework 与 SeleniumLibrary 结合使用来点击随机按钮生成器,HTML 是:

<div class="btn-number-password noselect">
<p class="btn btn-secondary btn-userpassword" data-keyboard="0">6 or 7</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="1">2 or 0</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="2">3 or 8</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="3">9 or 4</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="4">5 or 1</p></div>

它会将按钮生成到如下字段:

[6 or 7] [2 or 0] [3 or 8] [9 or 4] [5 or 1]

这些数字每次都会随机播放,所以我尝试使用文本进行点击,但我尝试的方法都不起作用。

有没有什么方法可以使用这些按钮中的文字来使用机器人点击?

Chandrashekhar 刚刚问了我的问题,而且成功了!再次感谢!

明确一点,答案是:

Click Element                      //*[contains(text(),'1')][1]
Click Element                      //*[contains(text(),'4')][1]
Click Element                      //*[contains(text(),'7')][1]
Click Element                      //*[contains(text(),'2')][1]
Click Element                      //*[contains(text(),'5')][1]
Click Element                      //*[contains(text(),'8')][1]

您也可以使用 class 来改进您的元素搜索:

Click Element                      //*[@class='new_window'][1]//*[contains(text(),'1')][1]