Home » Java » How to send text to the search field through Selenium Webdriver?

How to send text to the search field through Selenium Webdriver?

Posted by: admin July 28, 2018 Leave a comment

Questions:

Task:
search FAA in search box :
enter image description here

I have tried this:-

webdriver.select_tabs(search.btnSearch);

Thread.sleep(3000);
WebElement searchbox = driver.findElement(By.id("search-text"));
Actions builder = new Actions(driver);
Actions seriesOfActions = builder.moveToElement(searchbox).click().sendKeys(searchbox, "FAA");
seriesOfActions.perform();

WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"search-text\"]")));
element.sendKeys("FAA");
element.sendKeys(Keys.ENTER);

webdriver.enter_key(search.txtSearch, Keys.ENTER);
webdriver.enter_Text(search.txtSearch, "FAA");
webdriver.enter_key(search.txtSearch, Keys.ENTER);

Got this error:-

org.openqa.selenium.ElementNotVisibleException: element not visible
Answers: