Showing posts with label Selenium Automation Frameworks. Show all posts
Showing posts with label Selenium Automation Frameworks. Show all posts

Tuesday, January 15, 2013

Selenium Automation Frameworks






1
Selenium + Ant + Test NG
2
Selenium RC + PHPUnit + Ant
3


4


5


6


7


8


9


10








Selenium RC, Eclipse, Java - Hrmes framework
 

 
The HRMES is a test framework built for ALL testers of web based applications.
Supports Selenium RC, IDE, Grid etc.,  -   >> More


 
Selenium RC,TestNG, Eclipse

>> Video Clip 1

>> Video Clip 2

 
How to setup Selenium RC in Eclipse   - >> Video Clip
 
Setup Eclipse for Maven, TestNG, SVN, and Selenium  - >> Video Clip
 
One Good framework from Open2 site - >> More

Selenium Integration Testing For All Framework - >> Video Clip

Testing Testlink via Selenium RC - >> Video Clip

ROBOT Framework - Selenium RC & Java - >> Download from here      >> One more          >> another one
                                                     

                        

 Selenium & PHPUnit

Best Article ( step-by-step) to know the setup Selenium RC + PHPUnit - 
click here
 Best to learn & automate using Selenium with PHPUnit - click here  & 


                                                                                               - to download - www.phpunit.de

Integrating & Testing PHPUnit with Selenium - sebastian-bergmann.de

How to use Selenium - PHPUnit for automating functional tests - drupal

Selenium RC integration for PHPUnit - sebastian's github

Testing PHP/Web Applications with PHPUnit and Selenium - sebastian bergmann Video Clip

Pear site to download all the packages - click here 

Selenium Framework for PHPUnit - Mediawiki

Article on how to run phpunit with selenium RC - Devzone Article

Drunit - PHPUnit and Selenium RC integration for Drupal - Drunit

Exlusive Video clip for phpUnit y Selenium RC - >> Video clip

Article to how to install - PHPUnit, Testing_Selenium in Windows Vista - Click here ...

Blog from saucelab to integrate PHPUnit with Selenium - click here 

Yii framework - click here

Useful article with screenshots - click here   


Selenium RC & PHPUnit & Ant

How to integrate with ant script -- click here


Selenium & JUnit



A standard framework - Click here ...

Selenium RC with JUnit: -  
Click here ...




Selenium with JUnit & JMeter





Selenium Grid with PHPUnit

Integration of Selenium Grid with PHPUnit - video clip


Google code based frameworks







SAT - Selenium Ant TestNG Framework


Architecture


This framework is created using ANTTestNG and Selenium.
Through this framework, a user is able to create an automated test case which can be run later by executing a single command. The uses of different frameworks are as follows:
Selenium: This framework is needed for recording a testcase, exporting it into Java, and executing it on a browser
TestNG: This framework is used to organize different tests, and to report results.
ANT: provides the glue to hold everything together, and execute basic commands.

Pre-requisites:


Basic knowledge of Selenium IDE, Selenium RC, TestNG and ANT.

Setup:


1. Install Selenium IDE on your Firefox browser.
2. Make sure you have ANT installed.
3. Grab the testws.zip file from here. Unzip it into a directory of your choice.
About the sample 
There are 2 bundled samples:
1. AdminLoginTest.java: This test logs into the glassfish admin console using the username/password: admin/administrator. It then clicks on the 'Enterprise Applications' link, and tests to see if there are no applications deployed. Else, test will fail.
2. SimpleTest.java: This test accesses http://localhost:8080/ page, and tests whether the term "Glassfish Project" appears or not.
The config directory contains testng.xml file, and is a place holder for configuration files.
The lib directory contains required jar files, and is a place holder for other library jars/zips.
The test directory contains test java files and is a place holder for other test files.
Once the tests are run, build and test-output directories will be created.
The build directory contains compiled classes, and is a volatile directory that is deleted by the target clean in build.xml file.
The test-output directory contains result files, and is generated by TestNG.
Notes:
To run the bundled sample, follow the steps for "Execute your test through ANT" (see below).
Currently, I face some issues running this on IE. I have successfully been able to run tests using Firefox.

How To:


Write a test case
The basic structure that one has to follow to create a test case is:
1. Record a testcase using Selenium IDE (Firefox browser only), Export the test case into Java
2. Edit the test case – java file, and add TestNG annotations
3. Execute the test case using ANT
1. Record test using selenium IDE and export it into Java:
i. Open the website you’d like to test in Firefox browser
ii. Start the selenium IDE from your Firefox browser
iii. Ensure that the Base URL in Firefox is the same as the website you want to test
iv. Start clicking on the website. Selenium will record your actions.
v. When finished, do: File -> Export Test As... -> Java – Selenium RC and save the java file.
seleniumIDE-export.JPG
After exporting, your java test case should look like this:
selenium-java-test.JPG
2. Add TestNG to your test case:
i. Open the java test file you just created in an editor
ii. Add the following:
(a) to the import statements:
import org.testng.annotations.*; 
(b) To variable declarations:

private DefaultSelenium selenium;
private static String TIMEOUT_PERIOD ="10000";

(c) To The class:

@BeforeSuite(alwaysRun = true)
public void setUp(String browser) {
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080");
selenium.start();
selenium.open("http://localhost:8080");
}
@AfterSuite(alwaysRun = true)
private void stopTest() {
selenium.stop();
}

(d) After each statement in the test that will take time for a page to load:

selenium.waitForCondition("selenium.browserbot.isNewPageLoaded()", TIMEOUT_PERIOD);

(e) On top of the test method:

@Test(groups = { "<your test group name>" })
e.g. @Test(groups = { "roller" })

(f) Edit page to be opened. Make sure arg to ‘open’ method of selenium points to the right context root e.g. Ifhttp://localhost:8080/<context_root> is the correct URL to test, then since we already have tried to open localhost:8080 in setUp, we only need to open the context root page.
e.g. 
selenium.open("<context_root>");
iii. Save the test file
(a). (Optional) Update testng.xml file. TestNG uses this file to read which groups to execute and also to pass parameters to the test. This file is only required if build.xml file uses testng.xml file to run the test.
Note: in sample test included, testng.xml is used, and will need to be updated.
iv. Ensure that the test file you created is mentioned in the build.xml compile target.
3. Execute your test through ANT
i. Start domain required by your webpage. e.g. asadmin start-domain
ii. Start database if needed (Not needed for bundled sample test)
iii. Start selenium server e.g. cd testws/lib, java -jar selenium-server.jar
iv. Execute the command: “ant run” from ‘testws’. You should see a new firefox browser window open up, and run through your test.
v. Check reports generated by TestNG under ‘testws/test-output’ directory. Open the index.html to see different output from the test.
SAT-html-output.JPG
Console output:

SAT-cmd-output.JPG

Thursday, July 14, 2011

Selenium RC + PHPUnit

Install Steps:


Windows:
-------------

1. PHP Install:

    1.1 Precautions:  Before installing, first check is php available in your system. If so either delete or continue with existing one.
    1.2 Check system | enviroment variables, is path or variables are set, either delete or continue with same.
     1.3 NowiInstall PHP [ visit site - http://windows.php.net/downloads/releases/ download either msi or zip package.  Preferably in C:\php folder]

2. PEAR install:

     2.1  Precautions:  First check in your system, PEAR already exists.  If so continue or delete.
            If u r deleting means, need to delete all system environment variable those are set earlier.

     2.2  Open cmd prompt, goto php folder & install PEAR package.
             C:\php>go-pear.bat

    This will install the pear package, but some times for the packages latest PEAR version might be needed.  So visit the site, http://pear.php.net/package/PEAR/download to check the latest versions. & then type command as mentioned in the site.

        2.3  While installing, pear.bat will prompt to know the location for installing.
                 Carefully set the locations, by default choose C:\php

        2.4  To know, PEAR is install successfully, type in cmd prompt, C:\php> pear -config
               It displays all config settings & commands.

3. PHPUnit Install:

      3.1  Check PHPUnit package already exists in C:\php\PEAR folder.  If not, proceed as below.
   
      3.2  Before installing PHPUnit, need to initialize the channels(websites) from which dependency packages are to be downloaded.  To do this,

              C:\php> pear update-channels or pear channel-update      ; it will update all channels.
               OR
              discover each channel as below

                  pear channel-discover pear.phpunit.de
                  pear channel-discover pear.phpunit.com
                  pear channel-discover pear.symfony-project.com
                  pear channel-discover components.ez.no

       3.3  Now install PHPUnit.   C:\php> pear install phpunit/PHPUnit
               make sure u will get the message - install ok:  channel:<>/PHPUnit<version>
               If you did not get this message, instead any error message means, follow them carefully & try to succeed in installing the PHPUnit.
               After installing successfully, to check phpunit is installed correctly, then try to locate the file phpunit.bat in C:\php folder. If exists means, it is installed correctly.
               
4. Write & Execute PHP unit tests.

       4.1 Open any editor & write php test code.  Example:

             <?php
require_once 'PHPUnit/Framework.php';

class StackTest extends PHPUnit_Framework_TestCase
{
    public function testPushAndPop()
    {
        $stack = array();
        $this->assertEquals(0, count($stack));

        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
}
?>            

   4.2 Save file as Class name, StackTest.php in the c:\php folder.

   4.3  Run the test, C:\php> phpunit StackTest.php, will get result as below:

            PHPUnit 3.5.14 by Sebastian Bergmann.
Time: 1 second, Memory: 3.00Mb

OK (1 test, 5 assertions)


5. Explore more about PHPUnit testing, assertions -  http://www.phpunit.de/manual/3.4/en/writing-tests-for-phpunit.html


6. Selenium RC setup:
   
     6.1 Download selenium RC jar file & locate anywhere.  Ex: C:\Selenium|Selenium-server.jar

     6.2 Open cmd prompt, then run jar file,  C:\Selenium> java -jar selenium-server.jar
            Now selenium server starts running at the backend.

7. Preparing test script using Selenium IDE

    7.1   Open Mozilla firefox browser > Tools > Selenium IDE ( if not installed, install IDE as addon)





    7.2   Record your script > export as PHPUnit script.  


7.3   Selenium script in PHPUnit framework



7.4  Save file in C:\php under either class name or any of your choice.


8. Running the scripts

    8.1 In one cmd prompt, selenium server will be running.
    8.2 Open one more cmd prompt to run the script like C:\php> phpunit Example

          See below how the script will be executed






 

             
     
         

 
     

PHPUnit

What is PHPUnit ?


It is a unit testing framework for PHP.  Means best useful for the projects or products designed in PHP.
It is opensource tool, can be installed either any machine os.


How to Install PHPUnit ?


1. Install PHPUnit on windows - click here to know

Install PHPUnit on Windows

Install Steps:


Windows:
-------------

1. PHP Install:

    1.1 Precautions:  Before installing, first check is php available in your system. If so either delete or continue with existing one.
    1.2 Check system | enviroment variables, is path or variables are set, either delete or continue with same.
     1.3 NowiInstall PHP [ visit site - http://windows.php.net/downloads/releases/ download either msi or zip package.  Preferably in C:\php folder]

2. PEAR install:

     2.1  Precautions:  First check in your system, PEAR already exists.  If so continue or delete.
            If u r deleting means, need to delete all system environment variable those are set earlier.

     2.2  Open cmd prompt, goto php folder & install PEAR package.
             C:\php>go-pear.bat

    This will install the pear package, but some times for the packages latest PEAR version might be needed.  So visit the site, http://pear.php.net/package/PEAR/download to check the latest versions. & then type command as mentioned in the site.

        2.3  While installing, pear.bat will prompt to know the location for installing.
                 Carefully set the locations, by default choose C:\php

        2.4  To know, PEAR is install successfully, type in cmd prompt, C:\php> pear -config
               It displays all config settings & commands.

3. PHPUnit Install:

      3.1  Check PHPUnit package already exists in C:\php\PEAR folder.  If not, proceed as below.
   
      3.2  Before installing PHPUnit, need to initialize the channels(websites) from which dependency packages are to be downloaded.  To do this,

              C:\php> pear update-channels or pear channel-update      ; it will update all channels.
               OR
              discover each channel as below

                  pear channel-discover pear.phpunit.de
                  pear channel-discover pear.phpunit.com
                  pear channel-discover pear.symfony-project.com
                  pear channel-discover components.ez.no

       3.3  Now install PHPUnit.   C:\php> pear install phpunit/PHPUnit
               make sure u will get the message - install ok:  channel:<>/PHPUnit<version>
               If you did not get this message, instead any error message means, follow them carefully & try to succeed in installing the PHPUnit.
               After installing successfully, to check phpunit is installed correctly, then try to locate the file phpunit.bat in C:\php folder. If exists means, it is installed correctly.
               

                Example of errors i faced & fixed are:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




C:\php>pear install phpunit/PHPUnit
Failed to download pear/HTTP_Request2 within preferred state "stable", latest re
lease is version 2.0.0RC1, stability "beta", use "channel://pear.php.net/HTTP_Re
quest2-2.0.0RC1" to install
phpunit/PHPUnit can optionally use PHP extension "curl"
phpunit/PHPUnit can optionally use PHP extension "dbus"
pear/XML_RPC2 requires package "pear/HTTP_Request2" (version >= 0.6.0)
phpunit/PHPUnit requires package "pear/XML_RPC2"
No valid packages found
install failed






C:\php>pear channel-discover pear.php.net
Channel "pear.php.net" is already initialized


C:\php>pear install HTTP_Request2-2.0.0RC1
Failed to download pear/Net_URL2 within preferred state "stable", latest release
 is version 0.3.1, stability "beta", use "channel://pear.php.net/Net_URL2-0.3.1"
 to install
pear/HTTP_Request2 requires package "pear/Net_URL2" (version >= 0.3.0)
pear/HTTP_Request2 can optionally use PHP extension "curl"
pear/HTTP_Request2 can optionally use PHP extension "fileinfo"
pear/HTTP_Request2 can optionally use PHP extension "openssl"
No valid packages found
install failed


C:\php>pear install NET_URL2
Failed to download pear/NET_URL2 within preferred state "stable", latest release
 is version 0.3.1, stability "beta", use "channel://pear.php.net/NET_URL2-0.3.1"
 to install
install failed






C:\php>pear install NET_URL2-0.3.1
downloading Net_URL2-0.3.1.tgz ...
Starting to download Net_URL2-0.3.1.tgz (8,488 bytes)
.....done: 8,488 bytes
install ok: channel://pear.php.net/Net_URL2-0.3.1


C:\php>pear install HTTP_Request2-2.0.0RC1
pear/HTTP_Request2 can optionally use PHP extension "curl"
pear/HTTP_Request2 can optionally use PHP extension "fileinfo"
pear/HTTP_Request2 can optionally use PHP extension "openssl"
downloading HTTP_Request2-2.0.0RC1.tgz ...
Starting to download HTTP_Request2-2.0.0RC1.tgz (95,353 bytes)
.....................done: 95,353 bytes
install ok: channel://pear.php.net/HTTP_Request2-2.0.0RC1


C:\php>pear install phpunit/PHPUnit
phpunit/PHPUnit can optionally use PHP extension "curl"
phpunit/PHPUnit can optionally use PHP extension "dbus"
downloading PHPUnit-3.5.14.tgz ...
Starting to download PHPUnit-3.5.14.tgz (118,697 bytes)
..........................done: 118,697 bytes
downloading XML_RPC2-1.1.1.tgz ...
Starting to download XML_RPC2-1.1.1.tgz (68,431 bytes)
...done: 68,431 bytes
install ok: channel://pear.php.net/XML_RPC2-1.1.1
install ok: channel://pear.phpunit.de/PHPUnit-3.5.14


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

4. Write & Execute PHP unit tests.

       4.1 Open any editor & write php test code.  Example:

             <?php
require_once 'PHPUnit/Framework.php';

class StackTest extends PHPUnit_Framework_TestCase
{
    public function testPushAndPop()
    {
        $stack = array();
        $this->assertEquals(0, count($stack));

        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
}
?>            

   4.2 Save file as Class name, StackTest.php in the c:\php folder.

   4.3  Run the test, C:\php> phpunit StackTest.php, will get result as below:

            PHPUnit 3.5.14 by Sebastian Bergmann.
Time: 1 second, Memory: 3.00Mb

OK (1 test, 5 assertions)




5. Explore more about testing, assertions -  http://www.phpunit.de/manual/3.4/en/writing-tests-for-phpunit.html



             
     
           

   
       

Thursday, June 16, 2011

Selenium Automation Frameworks







Selenium RC, Eclipse, Java - Hrmes framework
 



 

The HRMES is a test framework built for ALL testers of web based applications.
Supports Selenium RC, IDE, Grid etc.,  -   >> More


 
Selenium RC,TestNG, Eclipse

>> Video Clip 1

>> Video Clip 2

 
How to setup Selenium RC in Eclipse  >> Video Clip
 

Setup Eclipse for Maven, TestNG, SVN, and Selenium >> Video Clip
 

One Good framework from Open2 site - >> More

Selenium Integration Testing For All Framework - >> Video Clip

Testing Testlink via Selenium RC - >> Video Clip

ROBOT Framework - Selenium RC & Java - >> Download from here      >> One more          >> another one
                                                     


                        


 Selenium & PHPUnit

Best Article ( step-by-step) to know the setup Selenium RC + PHPUnit -
click here

 Best to learn & automate using Selenium with PHPUnit - click here  & 




                                                                                               - to download - www.phpunit.de

Integrating & Testing PHPUnit with Selenium - sebastian-bergmann.de

How to use Selenium - PHPUnit for automating functional tests - drupal

Selenium RC integration for PHPUnit - sebastian's github

Testing PHP/Web Applications with PHPUnit and Selenium - sebastian bergmann Video Clip


Pear site to download all the packages - click here

Selenium Framework for PHPUnit - Mediawiki

Article on how to run phpunit with selenium RC - Devzone Article

Drunit - PHPUnit and Selenium RC integration for Drupal - Drunit

Exlusive Video clip for phpUnit y Selenium RC - >> Video clip

Article to how to install - PHPUnit, Testing_Selenium in Windows Vista - Click here ...


Blog from saucelab to integrate PHPUnit with Selenium - click here 

Yii framework - click here

Useful article with screenshots - click here  



Selenium RC & PHPUnit & Ant



How to integrate with ant script -- click here




Selenium & JUnit



A standard framework - Click here ...

Selenium RC with JUnit: -  
Click here ...










Selenium with JUnit & JMeter




Click here



Selenium Grid with PHPUnit


Integration of Selenium Grid with PHPUnit - video clip


Google code based frameworks
click here