ループしてそれぞれをクリックする必要がある webElements のリストがありますが、クリックするたびにページが更新されるため、StaleElementReferenceException が発生します。各要素は次のようになります。
<img src="images/english/edit.gif" border="0" height="24" width="47">
そこで、再帰的な方法を使用して各 webElement をクリックし、インデックスを次のインスタンスに渡し、リストを更新します。
public int enterDescription(int place) { リストの説明 = driver.findElements(By.cssSelector(img[src='images/english/edit.gif']));for (int index = 0; index < descriptions.size(); index++) { index = place; if(place==descriptions.size()) { return place; } else { descriptions.get(index).click(); enterDescription(place++); } } return place; }
これは、最初はメソッドがクラッシュする終了条件まで機能し、終了条件に到達すると、すべてのインスタンスを一度に終了する必要があります。何か案は?