这是我编写的代码当网络列表从下拉列表中选择第二个用户时出现以下错误,错误是由缓存中未找到的元素引起的-也许页面在查找后已更改
代码是
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class SimpleBrowseroperation
{
public static void main(String[] args) throws InterruptedException
{
WebDriver driver = new FirefoxDriver();
//WebDriver driver = new InternetExplorerDriver();
//WebDriver driver = new ChromeDriver();
//driver.navigate().to("https://google.co.in");
driver.navigate().to("https://testnwadmin.aditi.com/nwadmin/spages/home.aspx");
List<WebElement> ele = driver.findElements(By.xpath("//*[@id='divLoginSection']/div/div[3]"));
driver.findElement(By.id("Login1_txtEmailID")).sendKeys("testdata5@aditi.com");
//driver.findElement(By.id("Login1_txtPassword")).sendKeys("Testing1*");
driver.findElement(By.id("Login1_btnLogin")).click();
driver.findElement(By.xpath("//*[@id='sliding-navigation']/li[2]/a")).click();
String ViewMorelink="//*[@id='divContentHolder']/div[2]/table[%s]/tbody/tr[3]/td";
String ClkViewMore="//*[@id='divContentHolder']/div[2]/table[%s]/tbody/tr[3]//a[contains(text(),'View')]";
String Covered="//*[@id='divContentHolder']/div[2]/table[%s]/tbody/tr[2]/td/table/tbody/tr[%s]/td[2]";
String ViewDetails="//*[@id='divContentHolder']/div[2]/table[%s]/tbody/tr[2]/td/table/tbody/tr[%s]/td[3]/a";
String TableRowCount="//*[@id='divContentHolder']/div[2]/table[%s]/tbody/tr[2]/td/table/tbody/tr";
String ViewCarrier="//*[@id='divContentHolder']/div[2]/table[%s]/tbody/tr[2]/td/table/tbody/tr[%s]/td[3]";
String ClaimPayer="//*[@id='divContentHolder']/div[2]/table[%s]/tbody/tr[2]/td/table/tbody/tr[%s]/td[4]";
Select WebList=new Select(driver.findElement(By.xpath("//*[@id='ddlSelectUser']")));
List<WebElement> userlist = WebList.getOptions();
int usercnt=userlist.size();
System.out.println(usercnt);
String[] linkTexts = new String[usercnt];
int i = 0;
for (WebElement e : userlist)
{
linkTexts[i] = e.getText();
i++;
}
for(int usrcnt=0;usrcnt<=usercnt;usrcnt++)
{
WebList.selectByIndex(usrcnt);
> /
> somecode
> /
}
}
}