Wednesday, June 6, 2012

Firefox add ons used for Manual Testing

These days i am busy with one manual testing project. So, I found some very useful firefox add ons which i am sharing with you all :

1)  Awesome Screenshot :- Capture the whole page or any portion, annotate it with rectangles, circles, arrows, lines and text, blur sensitive info, one-click upload to share.

2)  CheckFox  :- This enables quick check/uncheck of checkboxes...

3)  Clear Cache Button :- Adds a clear cache toolbar button. After installing the extension, find the clear cache button in the toolbar customization...

4) Crossbrowser  :- Open a website in the Internet Explorer, Safari, Chrome and Opera with one click.

5) ETNote :- Helps tester to take notes during Exploratory Testing.
This tool will help a tester testing a homepage to save data from the browser, e.g. URL or text areas, depending on your settings. It has also a notepad function.

6) Firebug :- Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page...

7) Firesizer :- Allows you to resize the window to specific dimensions.

8) GroundSpeed :- Groundspeed is an add-on that allows security testers to manipulate the application user interface to eliminate annoying limitations and client-side controls that interfere with the web application penetration tests.

9) HTML Validator :- HTML Validator is a Mozilla extension that adds HTML validation inside Firefox and Mozilla. The number of errors of a HTML page is seen on the form of an icon.

10) Interclue :- Ever wanted to know what was behind the link before you clicked? Interclue tells you everything you need to know before you open yet another tab.

11) Remove Cookies :-  A very simple extension to remove all the cookies of currently opened site. It adds an option to the Right Click menu of the page, and a Clear Cookies Button to perform this operation. It displays the status of operation in the status bar.

12) RestClient, debugger for WebServices :- Notice: some important features (XML indentation and load old saved requests) are missing in version 2.0.0, please update to version 2.0.1.

13) Session Manager :- Session Manager saves and restores the state of all windows - either when you want it or automatically at startup and after crashes. It can also automatically save the state of open windows individually.

14) Show IP :- Show the IP address(es) of the current page in the status bar. It also allows querying custom information services by IP (right click) and hostname (left click), like whois, netcraft, etc. Additionally you can copy the IP address to the clipboard.

15) SQL Inject Me :- SQL Injection vulnerabilites can cause a lot of damage to a web application. A malicious user can possibly view records, delete records, drop tables or gain access to your server. SQL Inject-Me is Firefox Extension used to test for SQL Injection vulnerabilities.

16) SQLite Manager :- Manage any SQLite database on your computer.

Some other important add ons :-

1) Fire Math :- FireMath is an equation editor based on MathML, the mathematical markup language.
Find examples, FAQ, installation instructions and a discussion board at
http://www.firemath.info
Speed up scientific scripting! Improve your science!

2) IE NetRender :- Render the current page with IE NetRenderer

3) Launchy :- Launchy will enable you to open links and mailto's with external applications...

4) Opera View :- Open pages in Opera from Firefox context menus. Very usefull for web developers!

5) Regular Expression Tester :- Testing tool for regular expressions with color highlighting (including submatches) and helpers for creating expressions


 

 

Wednesday, May 9, 2012

How to automate lost focus through selenium.

Sometimes we face a problem while automating the form submit. All of the form fields are having some action on their lost focus.
The onblur event occurs when an object loses focus.
For example : I have two fields First Name and Last Name. When i enter first name and press tab then it loses its focus and onblur function gets called.
and its calls upperCase and it changes the first name in Upper case.
the same case with Last Name. When i enter last name and press tab it calls blur function lowerCase and changes the letters in lower case.

But the problem in automation is i cant automate lost focus. when we type in first name and last name it simply types in first name and last name text box.
It does not call onblur function upper case and lower case and does not change the letter respectively.

so, fireEvent is a special command in selenium which helps in automating onblur function.

this is html of the element and blur javascript functions :






Enter your First Name:


Enter your Last Nast:



Now in Selenium, Do this :


 
How this works is :

First this will type "ridihima" in First Name and then selenium.fireEvent("fname", "blur"); this will call the onblur fuction "upperCase()" which changes the First Name in upper case "RIDIHIMA".
then it types in Last Name and then selenium.fireEvent("lname", "blur"); which means it will press tab and lost the function and on the lost focus it calls blur function lowerCase which changes the Last Name in lower case.

Tuesday, May 8, 2012

Verify value in drop down list through regular expression

To find element drop down is easy but to find a drop down having some specific value in their list is difficult.
Go to www.ebay.in you will see there is drop down along with search text box.
How to verify a specific value "Collectibles" is in drop down list. Doing testing in Selenium, It will come as :  

How to select the value in drop down using regular expression.

There are situation when we need to select the drop down value with some partial text .
With the help of regular expression we can select the drop down value.

Monday, April 30, 2012

Software Requirement for Selenium


1) Firefox 10
2) Selenium 1.7.1 (http://seleniumhq.org/download/)
3) Firebug (https://addons.mozilla.org/en-US/firefox/addon/firebug/)
     Firefox 3.6 works with Firebug 1.7.3
     used for : allows developers to find elements on the page by using the find functionality.?? It has a JavaScript REPL.    REPL stands for Read-Eval-Print-Loop, which is an interactive shell that allows you to run JavaScript without having to create an entire page.
4) Firefinder (https://addons.mozilla.org/en-US/firefox/addon/firefinder-for-firebug/)
   used for : A very good tool for testing out XPath and CSS on the page. It will highlight all the elements on the page that match the selector to your element location.
5) For other browsers :
IE Developer Tools :  This is built into IE7 and IE8, which we can launch by pressing F12. It also has a number of features that Firebug has.
Google Chrome Developer Tools : This, like IE, is built into the browser and will also allow you to find the elements on the page and be able to work out its XPath.
6) Notepad ++ text Editor: for making user extensions and Add Ons
For selenium RC:
1       1) Java JRE. You can download it from http://java.sun.com.
2    2) Setting up RC :
1. Download Selenium Remote Control from http://seleniumhq.org/download.
2. Extract the ZIP file.
3. Start a Command Prompt or a console window and check whether java is installed by typing java in cmd. navigate to C:\Program Files\Java\jdk1.7.0_03. Mainly java is found here.
Now change the settings:

 
3    3)      My computer properties – Advance system setting – Environment variables – under system variables add new variable name: JAVA_HOME and variable value as C:\Program Files\Java\jdk1.7.0_03 . Click ok . Now under system variable search for path. Click edit – paste under variable value : %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Windows Imaging\:C:\Program Files\Java\jdk1.7.0_03\bin
      4)   Now navigate to where the ZIP file was extracted. Put that in command prompt 
       5)      Run the command java –jar selenium-server-standalone.jar and the output should appear similar to the following screenshot: 
 
          Remote Control has been set up.
6) IDE : For Dotnet Visual Studio 2010. And For java: Eclipse or IDEA Intellij.
7) For java : JUnit and For Dotnet: NUnit
8) For Grid:
  Install : Download from http://selenium-grid.seleniumhq.org/download.html
  Install Ant : Download from http://ant.apache.org/bindownload.cgi

Jmeter Software Requirement


Softwares required:

JRE
JMeter
JDK 1.5 or higher.

Selenium Syntax


11)      Working With Ajax : Whenever ajax is loaded. Always use a
       Command: WaitForElementPresent
       Target:  //div[@id=’ajaxid’]
22)      To Store Element that are on the page to use later in test. For eg. Test needs to pick a date and use it later so that you do not need to hardcode values into your test. 
       Command: Type
       Target: name of the textbox
       Value:  ${variableName} . (This variable name will come from : Right-click on the text, go to the storeText command in the context menu, and click on it. A dialog will appear just as below. Enter the name of a variable that you want to use. )
3)      Using element attributes in XPath queries:
      Target: xpath=//div[@class='classname'].
4)      Do partial match on attribute content: For example, if you wanted to access the element that has the text "This element has an ID that changes every time the page is loaded" in it, you will use //div[contains(@id,'time_')]. This is due to the first part of the ID always being static. Or use //div[starts-with(@id,’time_)]
5)      Find element that text it contains: To do this, your query will need to have the text() method call in the query. It will match the entire contents of the node if it has the format //element[text()='inner text'].  Example : //div[contains(text(),’element has a ID’)] or //div[text()=’This element has a ID’]
6)      We are going to find a button and then find its sibling. In this, the query that we will generate is equivalent to xpath=//div[@class='leftdiv']/ input[2]. We will start by finding the first element for our query, which is //input[@ value='Button with ID']. Place that into the Selenium IDE Target box and see which element it highlights. There is another button below the one that is highlighted, and that is the element that we need to work with in this section. The button is the next input item in the HTML, so it is elements following-sibling that we need. Our locator will look like //input[@value='Button with ID']/following-sibling::input[@ value='Sibling Button'] . Similarly, use preceding instead of following.
7)      Javascript : Let's imagine you are working against an auction site. The script will need to get the value of the last highest bid off the page and then add 2 to it. Let's try this in the Selenium IDE.
Command: storeText
Target: NAME OF Id
Value: Any name
Command: type
Target: Previous Value
Value: javascript{+storedVars[‘Name Of the id’]+2}
8)      Javascript within Verify or Assert : Let's say that you have stored a value from a different part of the test and now you need to verify or assert that the value is correct. (Create a step to verify that it is equal to 5*10 using the verifyEval command)
Command: storeText
Target: NAME OF Id
Value: Any name
Command: verifyEval
Target: javascript{5*10}
Value: ${Value} //Previous Value that we used
9)      Accessing Page with BrowserBot:
BrowserBot is the JavaScript object that allows Selenium to control the browser. It overrides access to the window, document, and other key browser JavaScript objects that we can normally access.
    
        Syntax is: var window = this.browserbot.getUserWindow();

 Imagine that you need to call a JavaScript function on the page. This could be because you are working against elements that Selenium can't interact with and your test needs to call into the API to put something on the page. Or you might have to write some tests to exercise the JavaScript functions on the page.
Syntax for Remote Control Server:
1)      To test testcase or test suite on any browser:   Open a Command Prompt and write.
Where jar file is place>java –jar selenium-server-standalone-2.20.0.jar –htmlsuite *firefox http://book.theautomatedtester.co.uk "c:\book\chapter 6\testsuite. html" "c:\book\chapter 6\result.html"
(Where jar file is place>java –jar selenium-server-standalone-2.20.0.jar –htmlsuite *name of the browser, name of the site “where test suite or test case is kept” “where result has to save”)
2)      Number of Browser to test Code :
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*conqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
3) Running Selenium IDE tests with User Extensions:
java –jar selenium-server-standalone.jar –userExtensions \\ path\to\extensions.js -htmlsuite *firefox http://book. theautomatedtester.co.uk c:\path\to\testsuite.html c:\path\to\ results.html

4) Running Selenium IDE tests withport:

Since, RC acts as a proxy between your tests and the application being tested; it has to use a port to listen for commands. There will be instances where you will not be able to use the standard 4444 port. When this happens, adding –port allows you to use a different port number without conflicts.
5) Running Selenium IDE tests with -firefoxProfileTemplate
If you require a special profile, or if you need to make sure that a specific Firefox Add-on is installed, use –firefoxProfileTemplate /path/to/firefox/profile. This command will take the profile that you want and then clone it to be used in your test.

6) Converting Selenium IDE tests to a C# :

*) Phase One: Record a Test using Selenium IDE
  •  All green, it passed.  Good.
  • Now we want to convert this test to C#.
  • Select “File ->Export Test Case as C# -> Save on Desktop as HTML File ” from the Selenium IDE window.
  • Next select all the C# code and copy it.
*) Phase Two: Setup the C# Test Project
  • Open up Visual Studio
  • Select “File ->New ->Project”
  • In the New Project window under project types, select “Visual C# ->Windows”
  • Select the “Class Library” Template and name it something like “TestingBlogSeleniumRc” and click “Ok”.
  • It will create the project along with a file called “Class1.cs”.  Paste your SeleniumIDE test into that file.
  • Rename “Class1.cs” to “FirstTest.cs”.
  • In the code, change the namespace from “SeleniumTests” to “TestingBlogSeleniumRc”:
  • Modify the class name from “Untitled” to “FirstTest”.  It’s good to change this so that if you add other tests, there won’t be any duplicated class names in the namespace (This has gotten me before, causing compile errors.).
  • We also have to modify the Selenium instantiation to launch Internet Explorer.  Where it has “*chrome”, change it to “*firefox”.
  • Where it has “http://change-this-to-the-site-you-are-testing/”, change it to “http://www.google.com”.
  • Next we need to add all the references so this thing will run.
  • Go to the solution explorer, and right click on the “References” and select “Add Reference…”
  • Hit the “Browse” tab and navigate to where you unzipped your SeleniumRC files.  Look in the dotnet client driver folder.  
  • Once you navigate to where the proper *.dlls are, select all of them and click “OK” to add them to the project.  (I know you can probably get away with adding less, but let’s keep it simple.)
  • Build the project to see if it works.  (Mine worked.  Hopefully yours did too.)
*) Phase Three: Running the Selenium RC test
  • In order to run the Selenium RC test, you first have to have the Selenium RC server running. Make a batch file.
(How to make .bat file:
Open Notepad and write this :
 @Echo Off
Echo starting Selenium Server
java -jar E:\Ridihima\Software\Selenium\selenium-server-standalone-2.20.0.jar
And save this as .bat File )
  • Next you need to launch the NUnit GUI to run the test from.  Since you installed NUnit, you should be able to navigate to it “Start -> All Programs -> NUnit 2.4.7 -> NUnit GUI (.NET 2.0)”
  • Once you open the NUnit runner, Click “File -> Open Project…” and navigate to the compiled dll from your test project.  For me, the path looks like this:
  • C:\Documents and Settings\dbrown1\My Documents\Visual Studio 2008\Projects\TestingBlogSeleniumRc\TestingBlogSeleniumRc\bin\Debug\TestingBlogSeleniumRc.dll
  • Once it loads, click on “Run” to start the test.
You must get rid of the try-catch exception block.  As long as you have that block in your test, your test will never fail.  Nunit counts on an exception being thrown when an assert statement fails.  If that exception gets caught, then Nunit thinks that the test passed.


Performance Test Case


Navigational Steps For Loadrunner



Navigational Steps For Loadrunner 

1.Creating Script Using Virtual User Generator
•    Start-> program Files->Load Runner->Virtual User Generator
•    Choose File->New
•    Select type and Click Ok Button
•    Start recording Dialog Box appears
•    Besides Program to Record, Click Browser Button and Browse for the Application
•    Choose the Working Dir
•    Let start recording into sections Vuser_Init and click Ok button
•    After the application appears, change sections to Actions.
•    Do some actions on the application
•    Change sections to Vuser_End and close the application
•    Click on stop Recording Icon in the tool bar of Vuser Generator
•    Insert the Start_Transaction and End_Transactions.
•    Insert the Rendezvous Point
•    Choose :Vuser->Run, Verify the status of script at the bottom in Execution Log.
•    Choose:File->Save.(Remember the path of the script).
2. Running the script in the Controller with Wizard
•    Start-> program Files->Load Runner->Controller.
•    Choose: wizard option and click OK.
•    Click Next in the welcome Screen
•    In the host list , click add button and mention the machine name Click Next Button
•    Select the related script you are generated in Vuser Generator(GUI Vuser Script,DB script,RTE script)
•    Select Simulation group list, cilck edit button and change the group name ,No of Vuser.
•    Click Next Button
•    Select Finish Button.
•    Choose: Group->Init or Group->Run or Scenario->Start.
•    Finally Load runner Analysis graph report appears.

Friday, April 27, 2012

Patterns and Scripts

Most arguments required by the Selenium API fall into two categories:
I) Patterns and II) Scripts

I) Patterns : 1) glob (the default) and 2) regexp

1) glob:pattern
             * (anything/nothing)
             ? (any single character)
Example: verifyTitle | glob:Technical *Writing

2) regexp or regexpi (for case-insensitive match)
All JavaScript’s regular expression metacharacters are supported, including:
* (0 or more of preceding character)
+ (1 or more of preceding character)
? (0 or 1 of preceding character)
{n} (n of preceding character)
a|b (alternation: a OR b)
[aeiou] (character class: any one of the chars)

Example: Verifying search results for course CIS-200W
/* Allow 0 to ~ spaces between department & dash */
verifyTextPresent regexp:CIS *-200W-
/* Disallow course numbers 000-199 and 300-999 */
verifyTextNotPresent -[0-13-9][0-9][0-9].?-
/* Disallow course numbers 201-209 */
verifyTextNotPresent regexp:-20[1-9].?-

P.S : Validation :

1)  Verify text:
2      Verify date:
3      Alert pop up:
4      Dynamic selection :
5       

II) Scripts:

1) storeEval ( script, variableName )

Example: storeEval | this.browserbot.bodyText().match(/ of about +([0-9]+)\./)[1] | hits

2) storeExpression ( expression,variableName )

Example: storeExpression | javascript{this.browserbot.bodyTe xt().match(/of about +([0-9]+)\./)[1]} | hits

Perform while loop in the Selenium IDE

This extension provides goto, gotoIf and while loop functionality in Selenium IDE. The image below shows a sample test case using goto, gotoIf and a while loop, all running successfully in Selenium IDE. 
The file linked at the end of this post should be saved as "sideflow.js" to your hard drive. Then the Options settings in Selenium IDE should set the Selenium Core extensions to include the path of this file, similar to the image below.
 ___sideflow.js:____________________________________________________

var gotoLabels= {};
var whileLabels = {};
// overload the original Selenium reset function
Selenium.prototype.reset = function() {
    // reset the labels
    this.initialiseLabels();
    // proceed with original reset code
    this.defaultTimeout = Selenium.DEFAULT_TIMEOUT;
    this.browserbot.selectWindow("null");
    this.browserbot.resetPopups();
}
Selenium.prototype.initialiseLabels = function()
{
    gotoLabels = {};
    whileLabels = { ends: {}, whiles: {} };
    var command_rows = [];
    var numCommands = testCase.commands.length;
    for (var i = 0; i < numCommands; ++i) {
        var x = testCase.commands[i];
        command_rows.push(x);
    }
    var cycles = [];
    for( var i = 0; i < command_rows.length; i++ ) {
        if (command_rows[i].type == 'command')
        switch( command_rows[i].command.toLowerCase() ) {
            case "label":
                gotoLabels[ command_rows[i].target ] = i;
                break;
            case "while":
            case "endwhile":
                cycles.push( [command_rows[i].command.toLowerCase(), i] )
                break;
        }
    }
    var i = 0;
    while( cycles.length ) {
        if( i >= cycles.length ) {
            throw new Error( "non-matching while/endWhile found" );
        }
        switch( cycles[i][0] ) {
            case "while":
                if( ( i+1 < cycles.length ) && ( "endwhile" == cycles[i+1][0] ) ) {
                    // pair found
                    whileLabels.ends[ cycles[i+1][1] ] = cycles[i][1];
                    whileLabels.whiles[ cycles[i][1] ] = cycles[i+1][1];
                    cycles.splice( i, 2 );
                    i = 0;
                } else ++i;
                break;
            case "endwhile":
                ++i;
                break;
        }
    }
}
Selenium.prototype.continueFromRow = function( row_num )
{
    if(row_num == undefined || row_num == null || row_num < 0) {
        throw new Error( "Invalid row_num specified." );
    }
    testCase.debugContext.debugIndex = row_num;
}
// do nothing. simple label
Selenium.prototype.doLabel = function(){};
Selenium.prototype.doGotolabel = function( label )
{
    if( undefined == gotoLabels[label] ) {
        throw new Error( "Specified label '" + label + "' is not found." );
    }
    this.continueFromRow( gotoLabels[ label ] );
};
Selenium.prototype.doGoto = Selenium.prototype.doGotolabel;
Selenium.prototype.doGotoIf = function( condition, label )
{
    if( eval(condition) ) this.doGotolabel( label );
}
Selenium.prototype.doWhile = function( condition )
{
    if( !eval(condition) ) {
        var last_row = testCase.debugContext.debugIndex;
        var end_while_row = whileLabels.whiles[ last_row ];
        if( undefined == end_while_row ) throw new Error( "Corresponding 'endWhile' is not found." );
        this.continueFromRow( end_while_row );
    }
}
Selenium.prototype.doEndWhile = function()
{
    var last_row = testCase.debugContext.debugIndex;
    var while_row = whileLabels.ends[ last_row ] - 1;
    if( undefined == while_row ) throw new Error( "Corresponding 'While' is not found." );
    this.continueFromRow( while_row );
}

____________________________________________________-


or check the below link : https://github.com/darrenderidder/sideflow

Wednesday, April 25, 2012

Cross browser compatibility testing tool


Adobe Browser Lab:
Adobe BrowserLab is without a doubt my favorite free cross browser compatibility testing tool on the web.
Adobe BrowserLab allows you to select what browsers and operating systems you would like to test on – everything from IE6 on a Mac to Firefox 5 on Windows.  It lets you save “sets” of browsers, compare browsers via dual or quad comparison windows and even allows you to control the zoom of the browser window. You can change which browsers you’d like to test under “Browser Sets.”
With a sleek interface, an almost instantaneous refresh rate and a comprehensive browser test list I’d wager that Adobe’s BrowserLab will meet a majority of people’s browser testing needs. Most likely only those operating corporate or e-commerce websites need the additional functionality of a tool like Litmus.
The best part about Adobe’s BrowserLab? It’s 100% free! Just sign up for a free Adobe account and start testing!
https://browserlab.adobe.com (free!)

Don’t forget it’s important to not only test browsers but different browsers on different OS’s (which the tools above do). Here’s a handy cross browser testing checklist you can refer to while cross-browser testing your website or application:

1)      Validate your CSS, HTML and XHTML
2)      Test your Ajax, JQuery and Javascript functionality
3)      Confirm accurate font size and font display
4)      Confirm accurate page layout, alignment and resolutions
5)      Test and confirm page displays properly when zoomed in/out in browser.
6)      Check for broken applications and links.
7)      Confirm all scripts and forms work.