• tahseenat

Handling Autocomplete with Selenium


Autocomplete or Auto Suggestion allows the browser to predict the value. When a user starts to type in a field, the browser should display options to fill in the field, based on earlier typed values. The autocomplete works with the following input types: text, search, URL, email, and date pickers.

In this example, we will focus on Handling Auto Suggestion or Auto Complete Textbox in Web-Based Applications like Google in Selenium WebDriver.

This Example helps to understand the usage of Synchronization – Explicit Wait in Real-time Scenarios. Also the usage of the method



  1. Open the browser

  2. Enter the URL https://www.google.com/

  3. Type chromedriver in the Search text box

  4. It displays the options for chromedriver

  5. Select the text ‘chromedriver selenium’ from the display options.


import java.util.List;

import org.openqa.selenium.By;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;

import org.testng.annotations.Test;

public class AutoSuggest {

@Test(description="Auto Suggest")

public void selectValues()


System.setProperty("webdriver.gecko.driver", "geckodriver.exe");

FirefoxDriver driver = new FirefoxDriver();




* Example for Visibility of Elements located by


WebDriverWait wait = new WebDriverWait(driver,30);


List<WebElement> list = driver.findElements(By.xpath("//ul[@role='listbox']//li"));

System.out.println("Auto Suggest List ::" + list.size());

for(int i = 0 ;i< list.size();i++)



if(list.get(i).getText().equals("chromedriver selenium"))








Wizdom QA has created an end to end course curriculum for the SDET profile. Our students will receive in-depth knowledge of the latest QA tools, techniques and programming languages.

As a registered student, you will learn Selenium WebDriver, Appium for Mobile App automation, API automation, CI/CD integration and many more.

We have studied the market carefully and understood that there is a huge demand for good SDET profiles, however, finding the right candidate is quite hard because of the lack of right skills and experience among job seekers.


Therefore we are here with 11+ years of hands-on and training 800+ students to experience to create one-stop-shop course content for Software Development Engineering in Test (SDETs).


Belgard Square West, Tallaght,

Dublin, Ireland

Phone & WhatsApp

+353 894740999




Additional Links

Wizdom QA Trainings | All rights reserved | 2019-20 ©

  • Facebook Social Icon