我想模拟在wordsearch在线游戏中选择单词的真实场景。需要找到的例子是“学校”,然后我会点击字母S并向右侧移动字母C H O O L,在选择/找到字服务器时会说成功。
考虑我已经确定了这个词,现在想要点击字母S并向右移动以选择C H O O L.
怎么做?
HTML:
<tbody>
<tr>
<td class="rf-tgrid">G</td>
<td class="rf-tgrid">S</td>
<td class="rf-tgrid">T</td>
<td class="rf-tgrid">J</td>
<td class="rf-tgrid">Z</td>
<td class="rf-tgrid">N</td>
<td class="rf-tgrid">P</td>
<td class="rf-tgrid">H</td>
<td class="rf-tgrid">M</td>
<td class="rf-tgrid">C</td>
</tr>
<tr>
<td class="rf-tgrid">S</td>
<td class="rf-tgrid">N</td>
<td class="rf-tgrid">N</td>
<td class="rf-tgrid">A</td>
<td class="rf-tgrid">L</td>
<td class="rf-tgrid">V</td>
<td class="rf-tgrid">F</td>
<td class="rf-tgrid">X</td>
<td class="rf-tgrid">H</td>
<td class="rf-tgrid">K</td>
</tr>
答案 0 :(得分:0)
这应该可行,如果有任何语法错误,请道歉,没有Java IDE
List<WebElement> allLetters= dropDown.findElements(By.className("rf-tgrid"));
for ( WebElement we: allLetters) {
if ( we.getText().contains( "Your school letters in some sort of List<> or Array[]"))
{
Actions action = new Actions(webdriver);
action.moveToElement(we).click().build().perform();
}
这样的事情应该有用。