Friday, December 29, 2017

How to handle Google dynamic search (auto suggestions) in Selenium?

This is one of the most asked Selenium interview question and this question is to test our ability to handle dynamic objects.

The scenario is when we are searching some text say "seleniumhq" in Google, we will get some auto suggestions listed while we are entering the text and we need to click on the suggestion that matches with our requirement (here our requirement is "seleniumhq").

The auto suggestions will be listed in a web list as shown in the below image.

We will follow below steps to achieve this challenge
  • First we need to locate the list ('ul') 
  • Then gather all the suggestion elements ('li'). 
  • Now loop through the suggestion elements and compare the text in it with the expected text.
  • If texts matched click on the suggestion, and break the process.
Check out the code below for better understanding.

The screenshot looks like below after clicking on the required suggestion.

Now we are able handle dynamic Google search, Great!!. Please comment your queries and suggestions on this topic. Thanks for reading!!
#seleniumbabu #HappyLearning


  1. I have read your blog its very attractive and impressive. I like your blog. selenium Online Training

  2. Thanks for your information, it was really very helpful: Buy Fack Reviews

  3. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. auto repair Manalapan NJ

  4. This is one awesome blog article. Much thanks again selenium online training

  5. If your looking for Online Illinois license plate sticker renewals then you have need to come to the right place.We offer the fastest Illinois license plate sticker renewals in the state.

  6. Great survey, I'm sure you're getting a great response. dodge challenger decal stripes

  7. Thanks, Experience with various technologies and businesses this is generally helpful.
    Still, I followed step-by-step your method in this selenium online training
    selenium certification
    selenium online training Hyderabad
    selenium online courses

  8. When looking for Nationwide Credit Card Merchant Accounts information, you will find that there are numerous different sources you can use. There is the old standby, the OE factory service manual, but is it always the best resource for auto repair information?

  9. Thanks for this blog post, I enjoyed it’s content and style. I came across this blog on the internet and today have additional it to my personal favourites list. I’ll be certain to arrive again quickly. Mega888 apk download

  10. At the point when numerous VW proprietors examine their VW auto they say the individual and portray them as though discussing an old companion. dealer ops

  11. I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. 2020 Keystone RV Fuzion 410

  12. In this case you will begin it is important, it again produces a web site a strong significant internet site: 2021 Winnebago Micro Minnie 2306BHS


Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...