0

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>
2
  • 2
    What is the problem? code not working or thrown exception or any else? Commented Oct 24, 2013 at 6:03
  • Code is not working.. Commented Oct 24, 2013 at 6:13

4 Answers 4

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

Try with this

WebElement dropDownListBox = driver.findElement(By.id("country"));

Select clickThis = new Select(dropDownListBox);

clickThis.selectByVisibleText("(+44) United Kingdom");

Hope it helps

Comments

1

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);

Comments

1

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();
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.