Friday, August 28, 2009

Use of getoptlong in Ruby

this post is to describe how to use getoptlong package in ruby. Once i need to use it while i have given a task to generate a csv file in a specified format and need to upload that file into my automated testing tool "TESTDROID". there are some snippet of code that may help you to write code for your own.

you need to require some gem:

the format of getoptlong comments for the help and the text for special help is as follows:


then i need to handle the usage according to my requirements. as you can see that requirement in the last snnipet. so i had to decide which usage option i need to call according to the help option. so i have written a method for this requirement just look at this:

now the question is to call or use wrtten code. so just look at this:


hope this may help you to implement this.
Cheers!!

Monday, August 3, 2009

Effective use of xpath in automation (Recursive Descent Xpath)

using xpath in the automation can let you down any time. so there is a big question what do we do when there is no option left except using xpath. so we have recursive descent xpath.it actually search for particular context element.
for example:




following is the description of recursive descent xpath from Microsoft:

An expression that uses the double forward slash (//) indicates a search that can include zero or more levels of hierarchy. When this operator appears at the beginning of the pattern, the context is relative to the root of the document.For example,
the following expression refers to all elements anywhere within the current document: