Wednesday, December 11, 2013

How to get XPATH for any Object in IE?

Are you stuck with an application that only works in IE? 

Do you want the XPATH of an element that can be seen only IE? Unable to replicate the scenario in Firefox. There are many Firefox add-ons like xpather, xpath-checker and firebug that will give you the xpath of an element in a second. But sadly there is no add-on or tool available that will do this for IE. For most cases you can get the xpath of the elements that fall in your script using the above tools in Firefox and tweak them a little (if required) to make them work in IE. But if you are testing an application that will work only in IE or the specific scenario or page that has this element will open-up/play-out only in IE then you cannot use any of the above mentioned tools to find the XPATH.

Well the only thing that works in this case is the “Bookmarklets” that were coded just for this purpose. Bookmarklets are JavaScript code that you will add in IE as bookmarks and later use to get the XPATH of the element you desire. Using these you can get the XPATH as easily as you get using xpather or any other Firefox add-on.


1. Open IE

2. Type about:blank in the address bar and hit enter

3. From Favorites main menu select--->Add favorites

4. In the Add a favorite popup window enter name GetXPATH1.

5. Click add button in the add a favorite popup window.

6. Open the Favorites menu and right click the newly added favorite and select properties option.

7. GetXPATH1 Properties will open up. Select the web Document Tab.

8. Enter the following in the URL field.
javascript:function getNode(node){var nodeExpr=node.tagName;if(!nodeExpr)return null;if(!=''){nodeExpr+="[@id='""']";return "/"+nodeExpr;}var rank=1;var ps=node.previousSibling;while(ps){if(ps.tagName==node.tagName){rank++;}ps=ps.previousSibling;}if(rank>1){nodeExpr+='['+rank+']';}else{var ns=node.nextSibling;while(ns){if(ns.tagName==node.tagName){nodeExpr+='[1]';break;}ns=ns.nextSibling;}}return nodeExpr;}

9. Click Ok. Click YES on the popup alert.

10. Add another favorite by following steps 3 to 5, Name this favorite GetXPATH2 (step4)

11. Repeat steps 6 and 7 for GetXPATH2 that you just created.

12. Enter the following in the URL field for GetXPATH2
javascript:function o__o(){var currentNode=document.selection.createRange().parentElement();var path=[];while(currentNode){var pe=getNode(currentNode);if(pe){path.push(pe);if(pe.indexOf('@id')!=-1)break;}currentNode=currentNode.parentNode;}var xpath="/"+path.reverse().join('/');clipboardData.setData("Text", xpath);}o__o();

13. Repeat Step 9.

You are all done!!

Now to get the XPATH of elements just select the element with your mouse. This would involve clicking the left mouse button just before the element (link, button, image, checkbox, text etc) begins and dragging it till the element ends. Once you do this first select the favorite GetXPATH1 from the favorites menu and then select the second favorite GetXPATH2. At his point you will get a confirmation, hit allow access button. Now open up a notepad file, right click and select paste option. This will give you the XPATH of the element you seek.

Thursday, May 16, 2013

Testing in Production (aka TiP)

Software services such as Gmail, Facebook, and Bing have become an everyday part of the lives of millions of users. They are all considered software services because:

  • Users do not (or do not have to) install desktop applications to use them
  • The software provider controls when upgrades are deployed and features are exposed to users
  • The provider also has visibility into the data center running the service, granting access to system data, diagnostics, and even user data subject to privacy policies.

It is these very features of the service that enable us to TiP. If software engineers can monitor production then they can detect problems before or contemporaneously to when the first user effects manifest. They can then create and test a remedy to the problem, then deploy it before significant impact from the problem occurs.

Read out more in my whitepaper here

Thursday, April 25, 2013

What really is software testing and why it is essential?

By definition, "Software Testing is the process of executing an application with the intent of finding defects in it". But Software Testing’s contribution is broader than its original definition. An experienced tester not only finds defects but also adds suggestions to bring out quality in the system.

In one of my previous projects, I suggested that the architect added an aggregated table to improve the performance of a report. When it was implemented, the performance of the report improved greatly. I personally feel Quality Engineer is a better term for a tester as he brings in a lot of quality into the system by identifying areas of failure and improvement.

There has been a greater awareness in organizations on testing in recent years. Organizations understand the cost of not testing and implementing for every product they are building.

In brief, testing is essential as:
1.      It identifies defects and hence, gives scope for greater quality to be built into the application
2.      It ensures the functional as well as the nonfunctional requirements have been properly met in the application
3.      It ensures that the product is giving business value to the customer
4.      It ensures that the possible product risks and known issues have been addressed

Exception in thread "main" java.lang.UnsupportedClassVersionError

Today, using Cygwin on my windows environment, I was trying to execute the following simple program:

class hellotext
public static void main(String[] args)
System.out.println("Hello World!");

And I was seeing:

Exception in thread "main" java.lang.UnsupportedClassVersionError: hellotext (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Now what’s wrong with this simple program?

Nothing really! It’s actually a problem with the environment.

If I do java –version and javac –version, then it returns different versions and that's the issue. 

Everything worked fine when I removed the duplicate JAVA from my system using Control Panel.

Wednesday, April 24, 2013

Welcome Testers

Today, while coaching few testers, I was explaining them the importance of reading testing blogs and one of them pointed out, what according to him, is a kind of bug. He told me that my original blog, doesn't contain any testing keyword! Is it really a bug???

Perhaps, for sure, it's an issue. Why? Because it's like you develop a software application and you name it after something unrelated. Will it be part of Google results when someone searches for testing blogs? Definitely, the probability is much less.

So, keeping in mind the excellent suggestion, I'm starting this new blog, and wow, it's name contains "testing". :)

Hoping that all the readers will get benefit from this blog in some way!!