Tuesday, September 25, 2018

Difference between Selenium RC and Selenium WebDriver

Hi guys, In this post, I am going to cover -

  • What is Selenium RC.
  • Different components of RC.
  • How RC works?
  • Evolution of WebDriver.
  • WebDriver VS RC.


Selenium RC





Selenium RC is also known as Selenium 1.0.

It has two components -

  1. Selenium remote control server.
  2. Client Library.

1. Selenium RC server 

Selenium RC server acts as a middleman between selenium commands and browsers. Selenium Server receives Selenium commands from test scripts, interprets them, and reports back the results of running those scripts.
2. Client Library
It provides a programming interface between each programming language and RC server. We need a programming language to create test script which has a set of selenium commands. Client Library provides a programming interface(API) which is nothing but a set of functions, which runs selenium commands from your own test script. There is a different client library for each of the supported programming languages.

How RC works?
  1. First, you write the test script.
  2. Before you start running the script, you need to start selenium RC server.
  3. The server will inject a JavaScript program called  Selenium core.
  4. Selenium Core is a JavaScript program. It is actually a set of JavaScript functions which interprets and execute selenium commands based on the browser's inbuilt JavaScript interpreter.
  5. Once you start running the script, the client library takes selenium commands one by one and passes it to the server.
  6. Server now passes the commands in the form of instructions to the selenium core.
  7. Selenium core executes them as JavaScript commands.
  8. The browser will obey the instructions of the selenium core and actions will be performed on the AUT(APPLICATION UNDER TEST).
  9. Based on the actions performed, browser relays its response to the server.
  10. The server then passes the response to the client library.
  11. Client library passes the response back to the script.
  12. Now script receives the response and can store it in a variable and report it as a success or failure.
https://automation-seleniumtutorial.blogspot.com/2018/09/difference-between-selenium-rc-and.html

So, one can observe that the writing script in RC and executing it is how much complex. The notable thing is the use of the server as a middleman. This makes the execution of script slow and hence performance.



Here comes the WebDriver!!!
Selenium 2.0 is also known as WebDriver.

How WebDriver works?

No concept of Server.
Yes, you don't need to start any server. A BIG relief!!!

It controls the browser from the OS level.
All you need are your programming language IDE(most of the case Eclipse) and browser to perform testing.


Now we will see the difference between Selenium RC and Selenium WebDriver -





  1. Speed-  As I discussed above, Selenium RC requires the server to execute test scripts across browsers. But, Webdriver makes a direct connection with the browsers. Thus, Webdriver improves the performance of execution speed as compared to RC.
  2.  Interaction with web page elements - Suppose, there is a web element which is disabled on the web page. If a user tries to enter something, then what is the expectation? Definitely, the user will not be able to enter anything in a disabled web page element. This is how Webdriver interacts with the page elements. It provides a realistic interaction with them. But this is not the case in RC. Selenium core like other javascript code can enter a value in the disabled text box(a web page element) also. In the past, many selenium testers complained about this weird behavior.
  3. API - Webdriver' API is more concise in comparison to RC's API. RC's API contains redundancies and confusing commands. User often get confused which commands to use type() or types(), click() or  mouseDown() or mouseDownAt(). Apart from that, the different browser interprets each of these commands in different ways too. Well, this is not the case in Webdriver. We have click() command for clicking, sendKeys() for entering or typing some data.
  4. Support for the browser - RC does not provide support for HTMLUnit browser. It a  headless browser because it is invisible that means NO GUI
  5. Customised reporting feature - Selenium RC has a feature to provide HTML based report details of all the executed test cases. But Webdriver does not provide such kind of feature.
  6. New browser support - As we know that Webdriver operates on OS level and there is a separate driver provided for each supported browser. Each Browser communicates with the OS in its own way. In such a scenario, if a new browser is released, then definitely it will also have its own way of communicating process with OS and also we won't have a separate driver for it too. So it is totally dependent on Webdriver's team when they will release a separate driver or whether they will provide any support for this new one or not.
This is all about Selenium RC and a quick difference between Selenium RC and Selenium WebDriver. In my next post, I will discuss WebDriver and how to configure WebDriver jar file with Eclipse.




Guys, do comment in the comment box and share your views about the post. If you have any query, please comment on it. It will help me to reach to you and help you to resolve your query.

Monday, September 24, 2018

selenium webdriver tutorial | selenium webdriver download

Hi guys,This is the post on -

Selenium WebDriver


 Here, I am going to cover -


  • Selenium Webdriver Introduction.
  • Different WebDriver APIs.
  • What is API?
  • Why WebDriver is  an API not a TOOL.
  • How to configure WebDriver jar files with Java project.


If you want to learn about the basics of Selenium, then you can refer my previous post here -  Selenium Introduction




Selenium Webdriver 


https://automation-seleniumtutorial.blogspot.com/2018/09/webdriver-introduction.html?m=1

It is a well designed API that allows automating test scripts for an application across different browsers.

It provides a number of APIs to automate the application across various browsers -


  • FirefoxDriver
  • GeckoDriver
  • InternetExplorer Driver
  • ChromeDriver
  • HTMLUni Driver
  • OperaDriver
  • SafariDriver
  • Android Driver
  • iPhoneDriver
  • EventFiringWebDriver



Note - Most of the people consider  Webdriver as a tool. But, it is not a tool. It is a collection of APIs.

So, what is an API ?

It stands for Application Programming Interface.

If you are familiar with Java, then you must know about methods/functions concept. We create methods to improve the re-usability of code. 

Let us consider a team of three automation testers is working on to test the Facebook application's "Home", "Profile" and "Find Friends" tabs. To do this, every tester has to login to the Facebook application and then they can reach to their respective tabs to perform testing. It means, "Login" functionality is common to all the testers. So, if they create a method to login to Facebook and call this method from their individual scripts, then they do not need to write the same login functionality's code in their scripts separately. This is called re-usability of code. 

Now comes to API 

It is a set of classes(where we write methods) written to achieve the desired functionality. It means you can configure it to your program and then you can call the methods available in it to perform a particular task for your program.

Example -  Java Database Connectivity(JDBC) is an API in Java that provides methods to query and update data in the database.
Similarly, Webdriver is an API that acts as an interface to provide communication between programming languages and browsers.

In the same way, Selenium WebDriver provides set of classes that consist of several commands(in selenium we call methods as commands) that we can use it in our test scripts to perform a particular task for us. 

So, remember guys, WebDriver is a collection of APIs. NOT A TOOL!!!



Pre-requisite- 

 before creating the first selenium script  -
  • The first thing you need is Eclipse IDE.  I am assuming that you all know how to install Eclipse IDE and configure it with JDK(Java Development Kit) and you have already created some basic programs using Java. If not, then you can search it on Google and you will get a guide on how to do the above-mentioned stuff. 
  • Next step is to download Webdriver jar files and configure it with your Java project. This I will show you.
How to configure WebDriver jar files?

1. Click here to download Selenium Java Client Driver.

You will be navigated to the below  Website - 

2. Scroll down below and stop at Selenium Client & WebDriver Language Bindings.


3. Since we will use the Java language, click on 'Download' link against 'Java' language. At the time of creating this post, the latest version of Selenium is 3.14. In future, the upgraded version will come. So, you can download the upgraded one. 


5. A jar file will be downloaded. Open the jar file by selecting 'show in folder' option. 
6. Extract the jar files. After extracting it will look like -


Note Remember the location of the extracted jar file.

7. Open Eclipse.
8. Now select  'File' > 'New' > 'Java Project' and click on it.


9. Give a project name let's suppose 'SeleniumProject' and Click on 'Finish'.


10. A Java project will be created under the 'Package Explorer' window.

11. Expand the 'SeleniumProject'.
12. Select 'SeleniumProject' > right click on it > Select 'Build Path' > Select 'Configure Build Path' and then click on it.
13. Select 'Libraries' tab and click on ' Add External Jar' button.
14. Navigate to the 'Extracted Jar File'.
15. Open the file and select jar file below 'lib' folder.
Then, click on 'Open' button.
16. Selected jar file will be downloaded. Again click on ' Add External Jar' button and click on 'lib' folder.
17. Select all the available jar files within 'lib' folder and click on 'Open' button.
18. Now you can see all the jar files are loaded. Click on 'Apply' and then 'Ok' button.
19. The 'Jar Files' will be added. You can verify by clicking on 'Referenced Libraries' under your 'SeleniumProject'.
20.  That's it!!! We have configured WebDriver jar files with our project.

So, guys, this is all about Selenium Webdriver and how to configure WebDriver jar files with your Java Project. In my next post, I will cover how to create the first selenium script and execute it in  'Chrome' and 'Firefox' browsers respectively.

Follow the complete tutorial of webdriver in the link- Selenium WebDriver





Guys, do comment in the comment box and share your views about the post. If you have any query, please comment on it. It will help me to reach to you and help you to resolve your query.

Thank you!!!







Sunday, September 23, 2018

Selenium Beginners Tutorial | Selenium Testing Tutorials




Hi guys, Welcome to  Selenium tutorial for beginners which is the one-stop platform to learn selenium from scratch till becoming an expert.
This is for those novice learners who have the vision to make a career in  Selenium automation. I have arranged everything in one place. I have created each and every topic in such a way that you will get a picture perfect idea of Selenium.                     

 This tutorial will make you ready for selenium automation and will help you with interviews also.

Here I am providing the roadmap to Selenium -


Basics Of Selenium


  1. Selenium Introduction
  2. Selenium RC VS Selenium WebDriver




Selenium WebDriver




TestNG


  1. TestNG Introduction
  2. Install and Configure TestNG Library in Eclipse IDE
  3. How to Write Selenium Script using TestNG Framework



Selenium Interview Questions

  1. Part 1

Sunday, September 16, 2018

What is Selenium - Selenium Introduction | Selenium Testing Tutorial


Hi guys, In this post, I am going to cover -

  • What is Selenium?
  • Advantages and disadvantages of Selenium.
  • Different types of Selenium.
  • Drawbacks of Selenium 1.0
  • Advantages of Selenium 2.0.
  • Selenium 3.0.
  • Who developed Selenium?
  • Different components of Selenium.



What is Selenium?

Selenium is an open source framework which allows automating tests of web-based application across browsers.

Yes across different browsers - Firefox, Internet Explorer, Chrome, Opera, Safari and so on.

Advantages -


  1. It's an open source testing framework. It means one can download it and can use it for automating. There is no cost involved, unlike QTP/UFT.
  2. As I mentioned, it supports testing across various browsers. One can create scripts for test cases and can execute it on different browsers.
  3. It allows creating automation scripts by various languages such as Java, Ruby, Python, JavaScript,  Pearl, C#, .NET, PHP and so on. 
  4. It supports various environments such as Windows, Linux, Mac and so on. It means you can execute your selenium scripts on any operating systems.


Disadvantages -


  1. It only supports testing of the web-based application.
  2. There is no technical support, unlike UFT. We need to rely only on the available customer communities. 
  3. It does not generate a test result report after the execution of tests. We need to integrate selenium with TestNG OR Junit frameworks for test result report generation.
  4. We can not perform image-based testing in Selenium. We need to integrate selenium with sikuli to perform image-based testing.
  5. We need to integrate selenium with Jenkins or Maven to achieve continuous integration testing.

Note - One thing can be observed from the disadvantages that to achieve some particular tasks we need to integrate selenium with other tools or frameworks. Though we need a number of integrations, yet Selenium is in huge demand as a testing framework because of its other advantages. Integration is a one-time activity but once done it will make the testing much easier.



Different types of Selenium - 


  • Selenium 1.0 - (Selenium IDE + Selenium RC +Selenium Grid)
  • Selenium 2.0 - (Selenium IDE + Selenium RC + Selenium WebDriver + Selenium Grid) or (Selenium 1.0 +Selenium WebDriver).
  • Selenium 3.0 - (Selenium IDE + Selenium WebDriver + Selenium Grid ) 

Note - In Selenium 3.0, Selenium RC has been removed.

Drawbacks of Selenium 1.0 -

Selenium 1 is the combination of Selenium IDE and Selenium RC.

Drawbacks of Selenium IDE - 


  • It comes as a plug-in with Firefox and now with Chrome only. It does not provide support for other browsers.
  • It does not provide conditional and iteration operations. It means you cannot put conditional and looping statements while writing scripts.
  • It does not provide Parametrization. It means you cannot perform data-driven testing for your application.
  • It does not provide support for error handling and database testing.
  • We cannot implement frameworks in IDE.
  • It does not support testing of iPhone and Android application.


Drawbacks of Selenium RC - 


  •  Selenium RC requires the server to execute test scripts across browsers. It slows down the tests execution.
  •  Suppose, there is a web element which is disabled on the web page. If a user tries to enter something, then what is the expectation? Definitely, the user will not be able to enter anything in a disabled web page element.But this is not the case in Selenium RC. It can enter a value in the disabled text box(a web page element) also. In the past, many selenium testers complained about this weird behavior.
  • RC's API contains redundancies and confusing commands. User often get confused which commands to use type() or types()click() or  mouseDown() or mouseDownAt(). Apart from that, the different browser interprets each of these commands in different ways too.
  • RC does not provide support for HTMLUnit browser. It a  headless browser because it is invisible that means NO GUI

To overcome these drawbacks, Selenium 2.0 version is released.

Selenium 2.0

Selenium WebDriver is called as Selenium 2.0.

Advantages

  • It provides drivers to work with all the supported browsers.
  • You can use conditional and looping statements in your script.
  • You can perform data driven testing.
  • It has error handling mechanism and provides support for database testing.
  • You can implement different frameworks with your project.
  • Since it directly interacts with browsers, it has faster execution speed.
  • It has clearly defined commands for each of the actions performed on web page elements.
  • It provides a realistic interaction with page elements.
  • It provides support for HtmlUnit browser.

Selenium 3.0

  • Selenium 2.0 had some bug issues. So those bugs got fixed and then Selenium team has released Selenium 3.0. We can say it is the bug fixes from Selenium 2.0. 
  • It does not Provide support to Selenium RC. Selenium RC APIs are moved to 'legacy' package.
  • The most important update is the introduction of Gecko Driver.Mozilla has made some changes to Firefox. If you are using Mozilla Firefox having version above 47, you have to install gecko driver and nave to configure it with your selenium script to automate AUT(Application Under Test) across Firefox browser. Below 47, you don't need to install. Whether you are working on Selenium WebDriver version 2 or 3, if your Firefox version is above 47, you have to install gecko driver. 



Who developed Selenium?


Don't you feel hectic, when you have been asked to do repetitious testing of 20 test cases, each having more than 20-30 test steps?

James Huggins also felt the same.

Well, this is the story of an engineer at ThoughtWorks. He was working on a web-based application that required frequent testing. He realized this repetitious testing insufficient. So, he created a JavaScript program that would automatically control the browser's actions. In another way, to automate the application. He named the program as JavaScriptTestRunner. Later, realizing it's potential to automate other web application also, he made the program open-source and later, renamed as Selenium core. That engineer is James Huggins who developed selenium in 2004.



Different components of Selenium - 

Selenium has four components - 
  1. Selenium IDE .
  2. Selenium RC .
  3. Selenium WebDriver.
  4. Selenium Grid.

1.Selenium IDE 
It comes as a Firefox plugin which provides record and playback feature. It means one can record and replay the tests in Firefox browsers. In the official website of selenium you can get that now selenium IDE comes as an extension of chrome also.

2. Selenium RC

It is a well-designed API(Application Programming Interface) that allows you to design test scripts in various programming languages and execute those tests scripts against different browsers. It requires server intervention to execute the tests across browsers.

3. Selenium WebDriver 

Like RC, WebDriver is also a well-designed API that allows you to design test scripts in various programming languages and execute those tests scripts against different browsers. Unlike RC, it does not require any server intervention to execute the tests.

4. Selenium Grid

It is a distributed environment that allows you to execute tests across different browsers and different OSs. It means you can execute tests scripts on IE on the window and on Safari on Mac. It greatly helps to reduce the tests execution time. It supports cross-browser testing.

So, guys, this is all about the basis of what is Selenium? and different components of selenium. In my next post, I have discussed :

  - Selenium RC

 - Selenium Webdriver

- difference between selenium RC and selenium webdriver.

Follow the link - Difference between selenium RC and Selenium WebDriver.




Guys, do comment in the comment box and share your views about the post. If you have any query, please comment on it. It will help me to reach to you and help you to resolve your query.

Thank you!!!