Selenium: I have to Select value from a drop down which is dependent on value selected in another drop down.
Ex: I have two drop downs 1 and 2. Value to be populated in 2 is dependent on 1. When I select value in dropdown 1 then page gets refreshed and value in 2 is populated. I have to select value in drop down 2.
I receive error Element is no longer attached to DOM
.
I tried using wait.until((ExpectedCondition<Boolean>) new ExpectedCondition<Boolean>()
but it does not help me. Same issue occurs.
I tried using WebElement
and Select
but neither helped. Can anyone help me figure out solution?
JavascriptExecutor executor2 = (JavascriptExecutor)driver;
executor2.executeScript("arguments[0].click();", <elementname>);
waitFor(3000);
Select <objectname1>= new Select(driver.findElement(By.id("<ID_for_drop_down_1>")));
selectCourse.selectByVisibleText("<valuetobeselected>");
waitFor(2000);
Select <objectname2>= new Select(driver.findElement(By.id("ID_for_drop_down_2")));
selectCourse.selectByVisibleText("<valuetobeselected>");
waitFor(2000);
I am using waitFor(2000)
a defined function for waiting for specified timeperiod.