Reputation: 31
I am facing issue while automating cascading drop down. Functionality is like this: On clicking drop down list and selecting one value, it will open another drop down according to the value selected in parent drop down.
Please find screenshots here: CLICK HERE
Here is my code:
Utility.SelectDropdown(driver, "//div[3]/div/div/select", "Test 1");
Utility.SelectDropdown(driver, "//div[2]/div/div/div[3]/div/div/select", "Test 2");
Utility.SelectDropdown(driver, "//div[3]/div/div/div[3]/div/div/select", "Test 3");
Utility class:
public static void SelectDropdown(WebDriver driver,String xpath,String value){
WebElement ele= driver.findElement(By.xpath(xpath));
Select dropdown=new Select(ele);
dropdown.selectByVisibleText(value);
I tried this using Wait and tab out, But it didn't work. It is selecting value in first drop down but unable to load child drop down. Hence I am getting error message like this:
" Cannot locate element with text: Test 2."
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Here is HTML of drop down:Click Here
Suggestions for this query will be appreciated.
Thank you.
Upvotes: 2
Views: 1748
Reputation: 31
Above issue was resolved with the help of keys function.
WebElement element8 = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("manPosDropD1_xpath"))));
element8.click();
element8.sendKeys(Keys.ARROW_DOWN);
element8.sendKeys(Keys.ENTER);
Thank you.
Upvotes: 1