Reputation: 545
I have tried entering the complete field value using selenium but this doesn't work. It requires to select from the suggestion shown. Anyone knows how to select from the suggestion show.
Note: I am using hybrid framework.
Upvotes: 2
Views: 2335
Reputation: 1
Just use sendKeys(Keys.Arrow_Down);
until the address you need and then use
sendKeys(Keys.Enter);
Upvotes: 0
Reputation: 492
something like the below one? If yes, replace Thread.sleep with explicit waits.
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.co.in/maps?source=tldso");
Thread.sleep(3000);
driver.findElement(By.id("searchboxinput")).sendKeys("Kora");
Thread.sleep(3000);
List<WebElement> autoSuggestions=driver.findElement(By.className("sbsb_b")).findElements(By.tagName("li"));
for (WebElement suggestions : autoSuggestions) {
if (suggestions.getText().contains("Koramangala Police Station")) {
suggestions.click();
Thread.sleep(3000);
break;
}
}
driver.quit();
Upvotes: 2