I am trying to click on an input field in the Website-link using xpath
usually it works for me for all urls.. but for this specific url whatever I try I cant click on the input field using selenium webdriver.
Webdriver loads the page but won't click on the element.
This is what I have tried so far: (it is a java project for test automation using Selenium webdriver)
System.setProperty("webdriver.gecko.driver", "C:\\Users\\nimal\\eclipse-workspace\\webdriver\\chromedriver.exe") ;
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("https://www.kayak.com/flights");
WebElement searchfield1 = driver.findElement(By.xpath("//*[@id='c5NwV-origin-airport-display']"));
searchfield1.click();
WebElement searchfield2 = driver.findElement(By.xpath("//*[@id='c5NwV-origin-airport']"));
searchfield2.sendKeys("Toronto");
I tried to first click on the div element using xpath, as then only I get the input field.
Then tried to send "Toronto" to the input field using xpath.
Any help or suggestions are most welcome.
//*[@id='c5NwV-origin-airport']returns no matches whereas//*[contains(@id,'-origin-airport')]returns 16 matches. Which one are you trying to sendkeys to?//*[@id='c5NwV-origin-airport-display']returns no matches for me. This is apparently a dynamically created ID and you'll need to narrow down the locator using additional information.