I have two different drop downs, first drop down consist of 5 values and second one has some ten values, my question is i want to iterate my drop downs in such away that for the each value in first drop down all the options should be verified, i have written the code as below, but after iterating two times it is giving "staleElementReferenceException ".. pls help me out.
public static void data() throws Exception {
dept = TestNGUtils.getWebDriver().findElement(By.xpath("//*[@id='dept']"));
Select deptdropbox = new Select(dept);
listb = deptdropbox.getOptions();
for (int s = 0; s < listb.size(); s++) {
System.out.println(listb.get(s).getText());
listb.get(s).click();
Thread.sleep(2000);
region = TestNGUtils.getWebDriver().findElement(By.xpath("//*[@id='SVC_UNIT_NAME']"));
Select regiondropbox = new Select(region);
regionlist = regiondropbox.getOptions();
for (int d = 0; d < regionlist.size(); d++) {
System.out.println(regionlist.get(d).getText());
String DD2 = regionlist.get(d).getText();
regionlist.get(d).click();
}
}
}