0

I am using two dropdowns. one is for selecting standard and another is for selecting section.before loading each dropdown, I set my driver to wait for certain period of time. however, I get StaleElementException. Please advise me where I am struggling? Below is my code

    @Test(dataProvider="LinkSubjects")
    {
        public static void LinkSubjects(String standName,String secName,String subName) throws IOException
   {
        WebDriverWait wait = new WebDriverWait(driver,10);
        Select standard = new Select(driver.findElement(By.id(Helper.getElementValue("standardID"))));
        standard.selectByVisibleText(standName);

        wait.until(ExpectedConditions.elementToBeClickable(By.id(Helper.getElementValue("SectionID"))));
        section.selectByVisibleText(secName);

       driver.findElement(By.xpath(Helper.getElementValue("button"))).click();
        }
}

//here I am reading data from excel and match with my app's table data

 try {
                for(idx=0;idx<trows.size();idx++){
                    if(idx==0){
                        idz=0;
                    }else{
                        idz = idx * perRowCols.size();
                    }
                for(idy=idz;idy<perRowCols.size()+idz;idy++){

                    Standard_TC_002.colsValue = tcols.get(idy);
                    for(int i=0;i<3;i++){
                        columnValue = String.format(Standard_TC_002.colsValue.toString(), i);
                    }       
                    if(columnValue.equalsIgnoreCase(subName)){

                            toggleArr[idx].click();

                            driver.findElement(By.name("commit")).submit();
                        }
                    }
                }
            }catch(StaleElementReferenceException ex){
                ex.printStackTrace();
            }
Anitha
  • 1,045
  • 3
  • 18
  • 31

0 Answers0