Hello Friends,

This is my third challenge from Selenium Vs Sahi Pro challenge round.

The earlier two where we pit Selenium against Sahi Pro are as below

Round 1 Challenge Post

Round 2 Challenge Post

Please go through the earlier post in understanding my insanity and the child stubbornness in me. I am determined to prove that Sahi Pro or any other tool for that matter will not really stand up to Selenium 🙂

While doing selenium automation, I always felt really happy in solving iframe issues and dynamic web elements which have AJax or JQuery or any other new age dynamism in the element population. It always gave me a kick.

My third challenge hence is geared towards the same theme. How does Sahi Pro stand up in handling iFrames and dynamic elements.

Below is the problem statement with steps involved

Problem Statement:

Go to http://jqueryui.com/autocomplete/

Type “J” in the Tags window

Select Java from the list


The above steps looks simple – but actually aren’t.. please keep on reading..


These are the challenges when doing in Selenium WebDriver:

#  Locating iframe

#  Handling autocomplete list (JQuery or Dynamic List)

# we will have to handle this using asynchronous wait implementation as autocomplete list takes some time to display

Here are the Steps someone has to do if the automation is being done using Selenium

#  Locating iframe

To understand iframe, we can say it is an html inside main html. There can be multiple iframe on the page.

In the latest web browsers, we can identify if page contains iframe but earlier it was very tedious task. These days if you do context click inside iframe area then it show frame options in context menu list that means this page has iframe OR, we have to look into page source.

Once we identify iframe, in Selenium we have to first switch inside iframe to interact with elements of iframe.

There are switching methods in web driver to handle iframe and it takes some parameter to handle the same.

Iframe can be handled via 3 ways in selenium webdriver but the main challenge is to identifying the iframe on the page.

# Handling autocomplete list and proper wait implementation as autocomplete list takes some time to populate

2nd thing autocomplete list takes some time to visible on the text box so it requires proper wait so that if it comes early or if it comes late then it should be handled by the scripts.

When we type “j” in search box, you will see the autocomplete list like below, after typing “j” it takes some time to display the auto complete list.Explicit Wait (Conditional wait) requires here before interacting with the auto complete list otherwise it might throw no such element exception.


Now, we can see the Autocomplete list and as per the test case we need to select “Java” from the list. Please note one point here some people think that this is a dropdown and they try to handle this with help of WebDriver Select class methods and that’s not the way because its not select tag and these values are not in option tag.

Once we know this is the dynamic list then we have to capture this in a list of WebElements then select “Java” from the list. To select “Java” from the list, we have to iterate the list once it match with “Java” select the same in the list.


Here is the script from Selenium/Java


package scripts;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class JqueryAutocomplete {
	public static void main(String[] args) throws Exception {
				// step 1
				WebDriver driver;
				System.setProperty("webdriver.chrome.driver", "src\\test\\resources\\drivers\\chromedriver.exe");
				driver = new ChromeDriver();	
				driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
				// step 2
				// To handle the frame (Using by index)
				WebElement element = driver.findElement(By.className("ui-autocomplete-input"));
				WebDriverWait wait = new WebDriverWait(driver, 10);
				List lst = driver.findElements(By.xpath("/html/body/ul/li"));
				for(int i=0; i < lst.size(); i++){
					//WebElement ele = driver.findElement(By.xpath("/html/body/ul/li["+i+"]"));
					WebElement ele = lst.get(i);



Considering that it was fairly tough to handle things and a lot of steps needed to be performed, I have a feeling that Sahi Pro may sweat this time.

Unlike last two times Sahi Pro automation went through without a hiccup, I was pretty sure that this time it will fail somewhere.

As I started experimenting it was again to my surprise that Sahi Pro could again do it in three simple steps.. It took me may be a little while to understand how Sahi Pro does but it was indeed a breeze.

Here is the script from Sahi Pro for all of us to see.


3 lines — that’s it…

Scrips screenshot from Sahi Editor :

It was little bit more work this time but it was really a breeze compared to what someone would have to go through in Selenium

Sahi Pro handled iframe automatically but need to mention which element is our main target element because by default it did not record the Tags textbox but Sahi Pro has powerful editor with pre built methods, so we can add the script from Sahi Pro editor.

See the below script to type “j” in Tags textbox:


As above we discussed that after typing “j”, application takes some time to populate the auto complete list so we have to define some conditional wait here to handle the same.

Please see the below applied conditional wait in the script


Hope you can easily understand the ease that Sahi Pro would have resulted in by looking at the above two code snippets.

Sahi Pro has asynchronous waits too.. and _wait works similarly. It’s implementation is extremely easy though.

This is again very surprising to me as it handled iframe and dynamic list very easily without switching in iframe.

We can see the difference how easily Sahi Pro automated the scenario. Sahi Pro handled all our challenges like iframe handling, auto suggested list handling. Even, we don’t need to look in the html code like what is an iframe and what is the dynamic list, everything handled by Sahi Pro..

While my stubbornness is intact, I am kind of getting a little jittery as I am throwing some tough challenges and Sahi Pro is not only handling the same with ease but shaking my confidence a little.

While I am throwing challenges to Sahi Pro, I need your help too. Please suggest some problem statements which we can use and challenge Sahi Pro.

If you want to challenge Sahi Pro on your own, go ahead and download the free trial version from the below URL


You can check more about Selenium and Sahi Pro on the following URL’s respectively



Leave a Reply