in Selenium java, sendkeys function is not entering the data but locating the exact location. Website: https://www.makemytrip.com/
driver.findElement(By.cssSelector(".langCard.fixedCard.bounceAni>span")).click();
WebElement from = driver.findElement(By.cssSelector("#fromCity"));
from.sendKeys("ben");
CodePudding user response:
To insert the search word there you need first to click the form element and then to insert the search word into the search input.
Something like this:
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".langCard.fixedCard.bounceAni>span"))).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#fromCity"))).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[@for='fromCity']//input"))).sendKeys("ben");
CodePudding user response:
Are you running this in headless mode? If not you can change the ExpectedConditions in the code snippet above to
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".langCard.fixedCard.bounceAni>span"))).click();
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#fromCity"))).click();
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//label[@for='fromCity']//input"))).sendKeys("ben");
