In this article, we will learn how we can automate/handle Auto suggestions or Autocomplete boxes using selenium Web driver.
But Before that,
What is AutoComplete or Auto
suggestion boxes?
In autocomplete boxes application try to
predict the values of typed text based on the input value provided earlier. For
e.g. in Google Search box whenever the user enters any value google
automatically tries to suggest to him the next text based on the value provided
earlier.
In this example, we will try to automate
Google Search box functionality in which I will try to search “selenium” and
based on this input provided it will automatically search “Selenium-web driver”
and click on the Search button.
Below is the code snapshot for this.
To understand the above code snapshot.
After entering selenium in the search box I
have taken all the suggestions in the list and iterate using for each loop and
click whenever I find selenium web driver as output.
The output of the above code execution is
Hi,
ReplyIf the Text is in Span tag under div tag then ??
Its not working for me !!