Sunday 6 May 2012

How to install Java?

How to install Java?

Click on the 'Free Java Download' button and proceed to download further and install Java on your system.

Java is an open source programming language.
After Java is installed successfully in your system you can see the Java folder is created inside the hard drive you have chosen while installing.

To write code and manage code in Java programming language one can use any editor or one can use IDE as well.

One can use notepad, notepad++ and many editors like that.
Or else one can use Eclipse, Netbeans and many IDE also.

For bigger projects we are supposed to use the IDE or else when the project complexity increases the number of java files also increases then it is not really possible to manage these files without using any IDE.

Saturday 5 May 2012

How to install firebug, & firepath?

How to install Firebug?

Navigate to the link: http://getfirebug.com/  and click on the 'Install Firefox' button.

Now follow the steps and install firebug as an add-on in the Mozilla Firefox browser.

How to install Firepath?

After you have installed firebug you can be able to install firepath.
Navigate to the url: https://addons.mozilla.org/en-US/firefox/addon/firepath/



Click on the button 'Add to Firefox' and follow the steps to install firepath on firebug.

After you have installed firepath successfully you can see as given below:


What is XPath?

XPath is normally called as XML Path.

We use XPath to navigate through elements, and attributes in the XML document.
As per W3C's, the XPath is a major element in XSLT standard - and XQuery and XPointer are both built on XPath expressions.

XPath is the language for finding information in an XML document.

What XPath is?
  • It is a syntax for defining parts of an XML document
  • It uses path expressions to navigate in XML documents
  • It contains the library of standard functions
  • It is vital element in XSLT
  • It is W3C recommendation



Normally in every web-based applications the XPaths or locators are unique addresses for each and every web object. It can be used with selenium to
perform operations on each object present in the webpage. In the web page each web-object has a primary unique XPath.

XPaths are derived from the html paths of the objects. One can install firebug, and on the top of firebug, one can install firpath. Both are installed as addons on Firefox.
 
When one extracts the xpath of the object, one can use that object using Selenium IDE, Selenium RC, or Selenium Web-driver. Xpaths are constants. They do rarely change. If there is a text-box, and the label of the text-box changes but the position does not change then xpath remains the same. Sometimes xpaths alo vary everytime you refresh the page. To handle variable XPath you need to use java-script functions. Varying xpaths always have a pattern.

Difference between Selenium IDE, Selenium RC, Selenium Webdriver

Selenium IDE Selenium RC Selenium Web-driver
Only works on Mozilla Firefox Works on almost all browsers.Does not work on latest version of Firefox/IE Works on latest versions of almost all browsers - Firefox, IE(6,7,8), Opera, Chrome
Record and play/run tool No Record and run No Record and run
No server required to start Server is required to start No server required to start
Core engine is JavaScript based Core engine is JavaScript based Interacts natively with browser application
Very simple to use. If using User extensions, you require knowledge on java script which makes the work a little bit tough. Its a simple and small API Complex and a bit large API as compared to RC
Not at all object oriented Less Object oriented API Purely Object oriented API
Cannot move mouse with it Cannot move mouse with it Can move mouse cursor
Full xpaths have to be appended with 'xapth=\\' syntax Full xpaths have to be appended with 'xapth=\\' syntax No need to append 'xpath=\\'
No Listeners No Listeners Implementation of Listeners is provided
Cannot test iPhone/Android applications Cannot test iPhone/Android applications Can test iPhone/Android applications
Cannot test iPhone/Android applications Cannot test iPhone/Android applications Can test iPhone/Android applications

Wednesday 25 April 2012

Configure Selenium RC server

How to configure 'Selenium RC' server?

To configure 'Selenium RC' server one has to download the latest jar file from the link given below: http://seleniumhq.org/download/


Click on the download link 'Download version 2.21.0' and download the jar file to the local hard drive of your system. 



After the download is complete, place the jar file in any place  in your hard driver. For instance I have place the jar file inside the 'C:' drive in my system.

->Just open the command prompt that is cmd prompt by: 
   Start-->Run-->type 'cmd' and click 'Ok'.
->Browse to the directory where 'Selenium RC' server jar file is located.
   In my case it is in the 'C:' drive.
->Now after going to that location in the command prompt simply type the following
   command as given in the screenshot below: 
    java -jar selenium-server-standalone-2.5.0.jar




If everything is fine, then one will be able to see the output like below given:
 Apr 25, 2012 10:36:56 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
22:37:01.226 INFO - Java: Oracle Corporation 22.1-b02
22:37:01.248 INFO - OS: Windows 7 6.1 amd64
22:37:01.342 INFO - v2.5.0, with Core v2.5.0. Built from revision 13516
22:37:01.787 INFO - RemoteWebDriver instances should connect to: http://127.0.0.
1:4444/wd/hub
22:37:01.790 INFO - Version Jetty/5.1.x
22:37:01.813 INFO - Started HttpContext[/selenium-server/driver,/selenium-server
/driver]
22:37:01.815 INFO - Started HttpContext[/selenium-server,/selenium-server]
22:37:01.816 INFO - Started HttpContext[/,/]
22:37:02.006 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@36d650
da
22:37:02.007 INFO - Started HttpContext[/wd,/wd]
22:37:03.125 INFO - Started SocketListener on 0.0.0.0:4444
22:37:03.126 INFO - Started org.openqa.jetty.jetty.Server@4115fa10

Now the 'Selenium RC' server is started so when the testcases created  for the 'Selenium RC' server one has to first start the 'Selenium RC' server and then run the testcases for the 'Selenium RC'.

Configure Selenium RC

How to download and configure/install Selenium RC?

Selenium RC stands for 'Selenium Remote Control'. 
Selenium RC can be configured in the following way:

First one needs to download the latest jar file from the selenium official website.

Second unzip the downloaded jar files and include them in the Selenium RC project.

Here are the steps given below:

One can download the Selenium RC from the given link below:


Click on the link in the screenshot given above, and download the zip file to the local system and unzip the downloaded zip file.

We will configure 'Selenium RC' using the 'Eclipse IDE'.

Now in the 'Project Explorer' right click inside it and click on the 'New -> Project' as given in the screenshot below:


Now in the 'New Project' dialog box click on the 'Java Project' and click n the 'Next' button.


In the next window give the project name and click on the 'Finish' button.


Now the user is displayed a screen like this given below:


In the left hand side right click on the project name and click on the 'Properties' option as given in the screenshot below:



Now in the properties dialog box click on the 'Java Build Path' and click no the 'Libraries' tab as given in the screenshot below:





In the above dialog box click on the 'Add External JARs...' button and browse for the jar files which is downloaded for the 'Selenium RC' as given in the screenshot below:



choose the jar files under the 'E:\workspace\selenium-remote-control-1.0.3\selenium-java-client-driver-1.0.1' folder and include all the jars and click on the open button the user is displayed the screenshot like this given below:


In the above click on the 'Ok' button and now one can see all the jars included in it. Now 'Selenium RC' is configured in your system with 'Eclipse IDE'. One can write the code in java and execute in the 'Selenium RC', and it will automate the browser actions as per the java code.

In 'Selenium RC' if you have to run test cases then you have to start selenium-server.jar which is needed to start 'Selenium RC' server. In 'Selenium Webdriver', there is no server which you need to start to run the 'Selenium Webdriver' based testcases.

Tuesday 24 April 2012

Configure Selenium Webdriver

How to download and configure/install Selenium Webdriver?

Selenium can be configured in the following ways:

First one needs to download the latest jar files from the selenium official website.

Second unzip the downloaded jar files and include them in the Selenium project.

Here are the steps given below:

One can download the selenium webdriver from the given link below:
http://seleniumhq.org/download/


Click on the download link as per the desired language you want to configure Selenium Webdriver. The example is shown for the Selenium Webdriver configured with Java language.

Once the download link is clicked the user is asked to save the zip files. Then save the zip files into the hard drive of your local system. When the zip files are downloaded properly just unzip the files to get files inside a folder.

We will configure using 'Eclipse IDE'. First we need to download the Eclipse from the 'Eclipse' website.

Go to the website: http://www.eclipse.org/downloads/ and download the following as given in the screenshot:




Please download the version "Eclipse IDE for Java EE Developers, 212 MB", and choose the 32 bit or 64 bit as per your system.

After the download is successful unzip the zip folder for 'Eclipse' and place the folder anywhere in your hard disk drive. In this example I have place it in 'E' drive. Now go to the 'Eclipse' folder as per the given the screenshot below:


Click on the 'eclipse.exe' and there will be a security dialog box. Just click on the 'Run' button and one can see the 'Eclipse' will launch with the following window:


Give the workspace name as per your desired requirement or else you can choose for different workspace location by clicking on the 'Browse' button. After you are done with setting your workspace path click on the 'Ok' button and it displays a window like this given below:


If you want to read about 'Eclipse' then click on the relevant links or else simply just click on the cross button of the 'Welcome' tab. Then the user is displayed with this window:

Now in the 'Project Explorer' right click inside it and click on the 'New -> Project' as given in the screenshot below:

Now in the 'New Project' dialog box click on the 'Java Project' and click n the 'Next' button.


In the next window give the project name and click on the 'Finish' button.



Now the user is displayed a screen like this given below:



Now 'Eclipse' has been configured in the system.
Now we will configure Webdriver into it using the 'Eclipse IDE'.

In the left hand side right click on the project name and click on the 'Properties' option as given in the screenshot below:


Now in the properties dialog box click on the 'Java Build Path' and click no the 'Libraries' tab as given in the screenshot below:


In the above dialog box click on the 'Add External JARs...' button and browse for the jar files which is downloaded for the Selenium Webdriver as given in the screenshot below:

choose the jar files under the 'selenium-2.21.0' folder and 'lib' folder and include all the jars and click on the open button the user is displayed the screenshot like this given below:

In the above click on the 'Ok' button and now one can see all the jars included in it. Now 'Selenium Webdriver' is configured in your system with 'Eclipse IDE'. One can write the code in java and execute in the Selenium Webdriver and it will automate the browser actions as per the java code.



Installing Selenium IDE

How to install Selenium IDE?

One can download Selenium IDE add-on from Selenium's website: http://seleniumhq.org/download
Click on the link as highlighted image:


Selenium IDE only works with firefox after it is installed as an add-on service in
 firefox.

Selenium IDE has a lightweight and easily understandable user interface. Unlike other testing tools the greatest power of Selenium IDE is to Record and Play/Run.
Selenium IDE is not just a record and play/run tool but, it is having the core engine which is based on javascript. 
One can write its own code in java script and extend the functionality of IDE. 

 After clicking on the download link it displayed like this:


Click on the 'Allow'. And now after few seconds it will display like this given below:


In this manner Selenium IDE will get installed into the Firefox browser as an add-on.

Once the Selenium IDE is installed you can find it under the: Tools -> Selenium IDE (option).

To verify the selenium IDE is installed properly just click on the 'Selenium IDE' option from the 'Tools' menu.
Now one can see the 'Selenium IDE' window is displayed as a popup over the existing firefox browser.
When the Selenium IDE window is displayed to the user by default it is in the recording mode.
Now you navigate to any website one can see all the steps and actions done in the firefox is being recorded by the Selenium IDE add-on tool.


If you want to stop the recording, then click on the 'Red' color button.

Features of Selenium IDE !
~ One can Easily record and run/playback
~ Web page element/object selection can be done by css, IDs, names, or XPath
~ Auto-complete is there for all Selenium commands
~ User can do Walk through tests
~ Debug the test cases and set breakpoints for verification
~ User can save tests as Java, Python, PHP, HTML, Ruby scripts, C#
~ It also Supports Selenium user-extensions.js file
~ It has the Option to automatically assert title of every page
~ One can easily do the customization through plugins

Selenium

Selenium: What is that?

Selenium is something which automates browsers. Overall selenium is used for automating web based applications, for testing purposes or web-based administration. Normally selenium supports most of the browsers.

Selenium is an open source automation testing tool which is basically used for web based application automation testing in several browsers.Selenium can't automate desktop based applications. Selenium is a collection of open source tools to automate web browsers and its functions across multiple platforms.

Selenium runs in almost all browsers and operating systems and it can be controlled by many programming languages and supported testing frameworks.
Selenium is very easy to use, solid and is very flexile.

Selenium supported Languages -
~ Java
~ C#
~ Ruby
~ Pyton
~ PHP
~ Perl

Selenium supported Browser -
~ Mozilla(All version)
~ Internet Explorer 6,7,8
~ Google chrome
~ Opera 8,9,10
~ Safari

Operating systems supported-
~ Unix
~ Linux
~ Mac
~ Solaris
~ Windows

To use selenium there is no restriction on language which one uses is totally not dependent of the language in which the application is made.For instance: If the application is made in Java language, it doesn't mean that one has to use selenium with java only. One can use selenium with the supported language mentioned above for any kind of web based applications. 

It is not mandatory if the application is under test is in Perl then one needs to write the selenium code in Perl.It is independent of the application under test. It is independent of the language in which the web based application is created.

One has to learn at least one of the language supported by selenium.

Elements of Selenium
~ Selenium IDE: It only installs in Firefox as an add-on. Firefox only supports selenium IDE. Just like other functional testing tools, it contains record and play/run feature. One can also extend IDE functionality with the help of the user extentions. Selenium IDE supports loops, regular expressions, if statements and many more features. It is based of Java Script. Using selenium IDE the test cases can be parametrized.

~ Selenium RC: Selenium RC is a client-server arrangement that allows to control web browsers locally or on other computers, using any programming language and testing framework.
RC works in multiple browsers and runs tests in the multiple browsers. Selenium RC can manipulate browser, check for assertions via corresponding RC driver. One can implement Selenium RC in any of the programming language mentioned above. RC also supports different frameworks as per the specific language. RC is the older version.

~ Webdriver: Webdriver can run browsers natively either locally or on remote machines. Webdriver also works in multiple browsers and runs tests in the multiple browsers. Testing frameworks are not wanted, but they can be helpful if one wants to automate tests. Webdriver supports Iphone and Andriod testing. It has latest features which is not available in Selenium RC. Webdriver doesn't require any server to work.

~ Selenium Grid: To run test cases parallely  on multiple machines and browsers Selenium Grid is used. By running tests on multiple servers at the same time, cutting down on time it takes to test multiple browsers or operating systems as a whole.