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.

Monday, April 23, 2012

Website Checklist


IN RESPECT OF WEBSITE

1. User Interface Testing
A. Easy to use
B. Instructions are simple and clear. Additionally, test that instructions are
correct
C. Is the site map is correct?
D. Does each link on the map actually exist?
E. Are there links on the site that are not represented on the map?
D. Is the navigational bar present on every screen?
E. Is it consistent?
F. Does each link work on each page?
G. Correctness of wording
H. No overuse of bold text,big fonts and blinking
I. Hyperlinked references are working
J. Are patterns, background colour and pictures distract the user?
K. Does all images add value to respective page?
L. Do these images waste bandwidth? In general use small pictures to reduce load.
M. Does wrap-around occurs properly?
2. Functionality Testing
A. Correctness of the functionality of the website i.e. the part that interfaces with the server and actually “does stuff”.
B. No internal and external broken links.
C. User submitted information through forms, needs to work properly.In order to test this, verify that the server stores the information properly and that systems down the line can interpret and use that information.
D. User input should get verified at system level according to business rules and error/warning messages should be flash to user for incorrect inputs.
E. If the system uses cookies, make sure the cookies work. If cookies store login information, make sure the information is encrypted in the cookie file. If the cookie is used for statistics, make sure those cookies are encrypted too, Otherwise people can edit their cookies and skew information
3. Interface Testing
A. If site calls external servers for additional data, verify that the software can handle every possible message returned by the external server.
B. To test browser and server interface, run queries on the database to make sure the transaction data is being retrieve and store properly.
C. Make sure system can handle application errors.
D. Make sure that system can handle other systems’ errors. e.g. losing the internet connection from server to the external server.
E. How the transaction is handled, if user does not initiate interruption.
4. Compatibility Testing
A. Operating systems
B. Browsers
C. Video settings
D. Printers
5. Load/Stress Testing
A. How many users at the same time can access without getting busy signal?
B. Can system handle large amount of data from multiple users?
C. Long period of continuous use: is site able to run for long period, without downtime.
6. Security
A. Each directory should have an index.html or main.html page so a directory listing doesn’t appear.
B. Historical pages should be removed from directories.
C. In order to validate users, if site requires user to login; verify that the system does not allow invalid usernames/password.
D. Is there a maximum number of failed logins allowed before the server locks out the current user?
E. Verify rules for password selection.
F. Does the server log track every transaction?
G. Does it track unsuccessful login attempts?
H. What does it store for each transaction?