use this. i used keys.return
package com.soapuitutorial.propertie;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class CopyOfExcercise_4 {
public static WebDriver driver;
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver",
"D:\\Vaibhav\\selenium2\\DatadrivenTestng\\src\\resource\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://www.cathaypacific.com/cx/en_IN.html");
Thread.sleep(5000);
driver.findElement(By.cssSelector("#depart-label")).clear();
driver.findElement(By.cssSelector("#depart-label")).sendKeys("Boston");
Thread.sleep(2000);
driver.findElement(
By.xpath("//a[starts-with(@id,'ui-id') and contains(text(),Boston)]"))
.click();
Thread.sleep(2000);
driver.findElement(By.cssSelector("#destination-label")).clear();
Thread.sleep(1000);
driver.findElement(By.cssSelector("#destination-label")).sendKeys(
"London");
driver.findElement(By.cssSelector("#destination-label")).sendKeys(
Keys.RETURN);
// Actions act = new Actions(driver);
// WebElement
// destination=driver.findElement(By.xpath("//a[starts-with(@id,'ui-id')]"));
// System.out.println(destination.isEnabled());
// System.out.println(destination.isDisplayed());
// act.moveToElement(destination).clickAndHold().build().perform();
Thread.sleep(5000);
// act.release(destination);
driver.findElement(
By.xpath("//*[@id='book-trip-tab-panel']/div/div/form/button]"))
.click();
}
}