Wednesday, January 25, 2012

Page Response - User expectations

Page Response - User expectations.

As per the study conducted by Forrester Research on behalf of Akamai, users are expecting the page to be downloaded in less than 2 seconds.

If your site page performance is less than 2 seconds locally, doesn't mean this performance is applicable to every user location. 
Performance is also impacted by distance between Data-center and end-user location. Need to deploy the Geographic load balancers  and CDN as per the requirement.
Below graphs shows the performance impact over distance.

Note: Above images copied from

Thursday, January 19, 2012

Webdriver - Kill IE process.

Webdriver - Kill IE process

I am working on Webdriver pageobjects, if test case get failed, system will not close the browser because it has not reached the statement driver.close.
There are lot of opened IE's at the end of test execution.
To overcome this issue, I have created following utility program that is called before every test execution to eliminate any opened IE's.

public void xKillIEs() throws Exception
final String KILL = "taskkill /IM ";
String processName = "iexplore.exe"; //IE process
Runtime.getRuntime().exec(KILL + processName);
Wait(3000); //Allow OS to kill the process

Later I am know that this is not a good idea.
Better implement the following

InternetExplorerDriver driver;

@BeforeClass(alwaysRun = true)
protected void setUp() throws Exception {
driver = new InternetExplorerDriver();

@AfterClass(alwaysRun = true)
protected void tearDown() throws Exception {


Sunday, January 8, 2012

Webdriver - How to handle Modal pop-up.

Webdriver - How to handle IE modal pop-up.

Issue Resolved for IE

Before we start understanding the model-popup, lets understand different pop-ups available on the browser. As per my understanding pop-ups are classified into.

1. HTML pop-up
2. JavaScrip pop-up
3. Win32 pop-up
4. Modal pop-up
5. File upload pop-up
6. File download pop-up

HTML pop-up - These are constructed using HTML, so it can be easily handled by Id or xPath. If you are able to locate the object using IE developer tool bar or Firebug then it is HTML popup.

JavaScrip pop-up - This popup is generated by "alert" statement, it can be handled using Webdriver or Java-script.
Alert Java Doc

Win32 pop-up - This popup is generated by windows, I came came across one popup of this kind. Webdriver can't handle it. Need to relay on Auto it or Java Robot class.

Modal pop-up - This is very specific to IE, Microsoft defined it as

When Windows Internet Explorer opens a window from a modal or modeless HTML dialog box by using the showModalDialog method or by using the showModelessDialog method, Internet Explorer uses Component Object Model (COM) to create a new instance of the window. Typically, the window is opened by using the first instance of an existing Internet Explorer process. When Internet Explorer opens the window in a new process, all the memory cookies are no longer available, including the session ID. This process is different from the process that Internet Explorer uses to open a new window by using the open method.

MSDN blog on Modal dialog

When user select Model popup, parent window is blocked waiting for the return value from the popup window. You will be not able to see the view source of the page, need to close the popup then only the parent window is activated.

How to get object properties of the model-popup? Copy the popup URL and open in a new TAB, then it will display in normal window format, where you can use IE Dev Toolbar or FireBug to capture properties.

Modal window popup activation client code looks like this

var val = window.showModalDialog(url + '?Ids=' + Id, null, 'dialogHeight: 600px; dialogWidth: 850px,dialogTop: 190px;  dialogLeft: 120px; edge: Raised; center: Yes;help: No; resizable: No; status: No;');

As per Webdriver team this issue is fixed on IE in 2.16.0, but still it is not working.

Workaround provided in Ruby using Fork, but there is no corresponding Fork command in Java.

As per my understanding, currently there is no solution. Even AutoIt can't handle popup objects because they belong to HTML not the windows, it can hardly handle the Window title. How to handle? This is blocking my major test cases.

1. Change the Modal popup design.
If you can influence and convince the the team, covert the model-popup into HTML Modal Popup, so that it can be easily handled in other browsers too.
2. Manipulating the page DOM.
3. Java Robot class
When browser open modal popup opened, focus automatically set on the popup. Now assume you don't have mouse input device, handle the elements using "TAB" "Enter" "Space". Robot class also perform the same events as stated above. Given delay of at-least 500ms in between two events, otherwise there are chances of missing the events.

      //To understand the concept, handle the pop-up without mouse
      //Same thing is performed through robot API
      //Text that need to be typed, character by character
      //Issue - If anyone changes the window focus, keys are lost
      Wait(5000); // Wait for model pop, as Webdriver don't handle need hard stop
        int keyInput[] =
          KeyEvent.VK_S, KeyEvent.VK_E, KeyEvent.VK_L, KeyEvent.VK_E,
          KeyEvent.VK_N, KeyEvent.VK_I, KeyEvent.VK_U, KeyEvent.VK_M,
        Robot robot = new Robot();

        for (int i = 0; i < keyInput.length; i++)


        robot.keyPress(KeyEvent.VK_ENTER); // Save Btn

File upload pop-up
If you are using file upload control SendKeys work perfectly fine on IE, else you need to relay on AutoIT.

File download pop-up
Need to depend on AutoIt, it works good with windows objects.