我遇到了这个问题。我想在我的 selenium webdriver 中循环这个函数:
driver.findElement(By.id("some id")).sendKeys("Example 1");
但我希望下一个生成的元素是“示例 2”、“示例 3”、“示例 4”等。有没有简单的方法?
<小时/>好的。我已经通过这样做来管理它:
int x = 1;
while (x<20) {
driver.findElement(By.id("some id")).sendKeys("Example" + x);x++; }
最佳答案
也许试试这个:
WebElement wE = driver.findElement(By.id("some id"));
for(int i= 1;i<20;i++){
wE.sendKeys("Example "+ i);
}
关于java - 在java中循环selenium webdriver脚本但具有不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25035171/