java,selenium,selenium-webdriver,xpathnavigator
You can actually type in that as below using sendKeys() WebElement toElement = driver.findElement(By.id("s2id_combobox2")); toElement.click(); driver.findElement(By.id("select2-drop")).sendKeys("Bangalore"); Here you can pass on if you have more cities by just changing the value in sendKeys()...
xpath,selenium-webdriver,didselectrowatindexpath,domxpath,xpathnavigator
Not a perfect solution, though in facebook scenario u can find first element as: (.//*[contains(text(),'Email')]/following::input[@type='email' or @type='text'])[1] Another thing to add if you are getting multiple elements for your query you can use: List<WebElement> txtList = new ArrayList<WebElement>(); txtList = driver.findElements(By.xpath(".//*[contains(text(),'Email')]/following::input[@type='email' or @type='text']")); and use txtList.get(0).sendKeys("abcd");...