Skip to main content

Posts

Showing posts from March, 2012

Useful Linux Commands - III

Here are some useful linux commands...
whoami - This command gives you the userid you are logged in aspwd - print working directory. When you type in this command it tells you which folder you are in and along with printing the path of the folderls - listing. This command will list out all the files and directories under the current directory sorted alphabeticallyls -F - This command lists all the files and directories with directories displayed with a trailing slash and executables have a * at the end of the executable namels -s - lists file sizes - displays in disk blocksls -s -h lists file sizes with human readable file sizeswc - word count displays lines, words, characters for a particular filewc -c wc -wwc -lcat - concatenate - prints the file contents one after anothersort - sorts the output head - - gets the topN results from a filemv - move - moves a filecp - copy - copies a filerm - removes a filermdir - removes a directory cd - change directory: users can change the director…

Useful Windows Commands

ipconfig: Used to see the IP address and the gateway mask. Can also be used to ipconfig /all: Displays all the available information for a systemipconfig /displaydns: This will display the local dns fileipconfig /flushdns: This command will clear the local dns filesysteminfo: Get the operating system information using this commandsysteminfo /S <systemname> /U <username>: Get the operating system information for a remote system using this commandtasklist: Does the same thing that starting a task manager would do…Display a list of tasks running on the system. taskkill /im <imagename>: Kills the process with the image name providedtaskkill /pid <processid>: Kills the process with the process id providedtype: read a file from command line using type…netstat: You can get to know who/what is getting connected to your system netstat –a: displays all connection infonetstat –b: displays the executable name in the netstat outputnetstat –n: sorts the netstat output in num…

AJAX Testing–Some Useful Links

Apache Commons StringUtils.isEmpty() vs Java String.isEmpty()

You might want to test for if a String is empty many a times. Before we jump onto the numerous solutions available let us take a look at how we define “Empty String”The difference in the two methods given by Apache and Java are dependent on how we define an empty string. Java String.isEmpty returns a boolean true if the string’s length is zero. If the string has null it throws NullPointerExceptionApache StringUtils.isEmpty returns a boolean true if the string is either null or has length is zeroThus its purely dependent on how you are defining “empty string” in your program which will decide which function to use…BTW if you want to skip using Apache Commons funciton and would want to stick to java then you can have your own function like this: public static boolean isEmptyOrNull(String strStringToTest) {
                 return strStringToTest == null || strStringToTest.trim().isEmpty();
}

verifyTrue vs verifyEquals to compare strings

There is a clear winner here! Lets explore which one is better.

Here is the scenario:
“Lets say I have to test if the appropriate tooltip is flashed for a component”
To get to the code directly, lets say I already have the tooltip text stored in a variable. Now all I have to do is to compare this string to the components tooltip text which I would get at runtime.
So the algorithm would be
Have the Expected Tooltip text stored in a variableGet the Actual Tooltip text for the component Compare the two strings – you should get the exact text
We usually tend to use verifyTrue to compare because according to our algorithm we are expecting the result of the string comparison to be TRUE

There is nothing wrong in using verifyTrue as if your test passes there is no difference in using verifyTrue or verifyEquals. The actual difference comes into picture only when your test fails.

String varExpectedTooltipText = “Some tooltip”;
// Method 1 - verifyTrue(selenium.getAttribute("componentI…