Tuesday 7 January 2014

How to handle autocomplete box in web driver

How to handle autocomplete box in web driver?

driver.findElement(By.id("your searchBox")).sendKeys("your partial keyword");
Thread.sleep(3000);
List <WebElement> listItems = driver.findElements(By.xpath("your list item locator"));
listItems.get(0).click();
driver.findElement(By.id("your searchButton")).click();



4 comments:

  1. Hi, can you please tell me, how to press the enter button after typing in selenium webdriver.

    ReplyDelete
    Replies
    1. driver.findElementByXPath("//*[@id='MainContent_txtPincode']").sendKeys("20130,Keys.Enter");

      Delete
  2. Hi Helan,
    its working for Chrome, but in firfeox its not working for me, any idea

    ReplyDelete