Reputation: 1423
I want to select the value from the drop down (drop down values changes when i change the values of previous drop down on the same page.) i have tried but nothing happened.
Java Code:
driver.findElement(By.xpath("//* @id='ctl00_CPHPageContents_rcbBranch_Input']")).sendKeys(Keys.DOWN);
//search.sendKeys(Keys.TAB);
HTML:
<tr>
<td class="rcbInputCell rcbInputCellLeft" style="width:100%;">
<input id="ctl00_CPHPageContents_ddlAssignedTo_Input" class="rcbInput radPreventDecorate" type="text" value="ghaffar, a" name="ctl00$CPHPageContents$ddlAssignedTo" autocomplete="off"/>
</td>
Upvotes: 0
Views: 34057
Reputation: 49
Try it this
public void(string[item])) {
WebElement dropDown = driver.findElement(By.id("countTd"));
dropDown.click();
driver.findElement(By.xpath("//td[@id='countTd']/span[text()='" + item + "']")).click();
}
Upvotes: 1
Reputation: 1796
1st you deselected all the values in the multi select box then select the values which you want.. It is working properly..
Log.info("Clicking on Softwarepack dropdown");
JavascriptExecutor execu = (JavascriptExecutor)driver;
execu.executeScript("document.getElementById('TestID').style.display='block';");
Select sel = new Select(driver.findElement(By.id("TestID")));
sel.deselectAll();
sel.selectByVisibleText("Value");
Thread.sleep(6000);
Upvotes: 1
Reputation: 253
Try with this
WebElement dropDownListBox = driver.findElement(By.id("country"));
Select clickThis = new Select(dropDownListBox);
clickThis.selectByVisibleText("(+44) United Kingdom");
Hope it helps
Upvotes: 2
Reputation: 1251
Selenium has special class designed to interact with drop down lists called Select. From there you can easily choose option by id, index or displayed value.
Upvotes: 2