![]()
API Guide - Utilities |
Courses in c#, ruby, shell scripting, Software testing courses and more
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||
General utilties that are used in various places in the package.
Return a compact representation of the string. Usually used for making a neat representation of long strings.
The first argument is the string to be compacted.
The second argument is an optional argument - The maximum number of characters to use at the start of the returned value. If nothing is specified, defaults to 10
The third argument is an optional argument - The number of characters to print at the end of the output string. If nothing is specified, defaults to 5
If the string is greater than <size>, then only the first <size> characters are displayed at the begining of the output. If the string size is greater than <size> + <tail>, then all other characters inbetween the begining and last <tail> characters are skipped and three dots are displayed instead.
For example, if the you say: compact("These are long sentence which are not to be seen completely", 5, 5), then the output looks like:
"These...etely"
Compare a string with another string or regular expression.
The first argument is the string that we want to compare. The second argument is the reference string or regular expression against which the first argument must be compared.
If the second argument is a string, then an exact match search is done. If the second argument is a regular expression, then a regex match is done.
returns true if the two arguments match, false otherwise.
Get a ‘Processed’ value for the string argument passed. Depending on the string format, the returned value could be the string itself or could be ‘a ruby evaluated value’. If the string begins with ‘eval’ then the text following ‘eval’ is actually evaluated. Otherwise the string itself is returned. Eg. eval_parameter("ruby is good") returns "ruby is good"
eval_parameter("eval ENV[‘QWT_HOME’]/bin") returns
c:QantomWETin
Note that the parameter to evaluate can only be string concatanation You cannot say "eval 3+2" and expect an answer of 5
Convert a path into an absolute path. Also if the incoming path is in unix style (’/’ as separator), converts it to dos style. If the second optional parameter is specified as false, then ’’ is not added to the end of the path
Utility method to construct a dictionary of parameters using an array of arguments.
Using the previous style of coding WET, when you need to identify objects, you had to say, Object("name:=n1"; "id:=i1" …). The idea is that all the arguments have to be matched to declare success.
This method takes a multiple argument list and converts into a dictionary of name-value parameters.
While processing the arguments, if any of the ‘value’ in the name-value pair looks like a regular expression, then the dictionary’s value is a Regex instance instead of a string
| WET is a opensource automated web testing tool which uses Watir as the library to drive web pages. WET drives an IE Browser directly and so the automated testing done using WET is equivalent to how a user would drive the web pages. WET extends the scripting abilities of Watir and also offers the convenience of recorders. It is licensed under LGPL and BSD style open source licenses. |