Monday 23 October 2017

How Webdriver Works

  • for each Selenium command, a HTTP request is created and sent to the browser driver
  • the browser driver uses a HTTP server for getting the HTTP requests
  • the HTTP server determines the steps needed for implementing the Selenium command
  • the implementation steps are executed on the browser
  • the execution status is sent back to the HTTP server
  • the HTTP server sends the status back to the automation script





Selenium History

  • Selenium was originally developed by Jason Huggins in 2004 as an internal tool at ThoughtWorks. Huggins was later joined by other programmers and testers at ThoughtWorks, before Paul Hammant joined the team and steered the development of the second mode of operation that would later become "Selenium Remote Control" (RC). The tool was open sourced that year.
  • In 2005 Dan Fabulich and Nelson Sproul (with help from Pat Lightbody) made an offer to accept a series of patches that would transform Selenium-RC into what it became best known.
  • In 2007 Simon Stewart at ThoughtWorks developed a superior browser automation tool called WebDriver.
  • In 2009, after a meeting between the developers at the Google Test Automation Conference, it was decided to merge the two projects, and call the new project Selenium WebDriver, or Selenium 2.0.
  • In 2008, Philippe Hanrigou (then at ThoughtWorks) made "Selenium Grid", which provides a hub allowing the running of multiple Selenium tests concurrently on any number of local or remote systems, thus minimizing test execution time. Grid offered, as open source, a similar capability to the internal/private Google cloud for Selenium RC.

The name Selenium comes from a joke made by Huggins in an email, mocking a competitor named Mercury, saying that you can cure mercury poisoning by taking selenium supplements. The others that received the email took the name and ran with it.

WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application.

WebDriver is an interface which contains set of abstract methods which will be implemented by the FirefoxDriver, chrome driver, InternetExplorerDriver, Safari Driver, Opera Driver.

Webdriver Supported Browsers
The existing drivers are the
1.      ChromeDriver,
2.      InternetExplorerDriver
3.     FirefoxDriver
4.     OperaDriver 
5.     HtmlUnitDriver






Monday 16 October 2017

Why there is no need of external Firefox driver like IE and chrome in selenium2.0..?

Answer:
Firefox driver is included in the selenium-server-stanalone.jar available in the downloads. The driver comes in the form of an .xpi (Firefox extension) which is added to the Firefox profile when you start a new instance of Firefox Driver.

How the Safari driver works:
Ø  The Safari Driver is implemented as a Safari browser extension. The driver inverts the traditional client/server relationship and communicates with the Webdriver client using Web Sockets.
Ø  It is just an extension that is created and used to communicate with Firefox, the other browsers & drivers simply don't follow the same implementation and thus, you are required to start drivers & executables for the others.
How IE Driver Works:
The IEDriver uses very low-level Win32 API calls to do some of it’s work, the Firefox Driver or Chrome driver doesn't need to do this
How Gecko Driver Works:
Ø  Gecko Driver is the link between your tests in Selenium and the Firefox browser.
Ø  Gecko Driver is a proxy for using W3C Webdriver-compatible clients to interact with Gecko-based browsers i.e. Mozilla Firefox in this case.
Ø  As Selenium 3 will not have any native implementation of FF, we have to direct all the driver commands through Gecko Driver.
Ø  Mozilla has created the gecko driver binary for use with Firefox v48 and later.
NOTE: If using Firefox v47 and earlier then the following can be ignored as it uses the native Firefox browser implementation.

In order for Selenium to hook into Firefox the Geckodriver Binary Path System Property must be set before instantiating the WebDriver.
webdriver.gecko.driver = path/to/geckodriver
The following is sets the property in Java.
System.setProperty("webdriver.gecko.driver","path/to/geckodriver");
WebDriver driver = new FirefoxDriver();
As of 2017-03 the latest Geckodriver must be used with Selenium v3.3 and later.

Ø  The reason for initializing the InternetExplorerDriver and Chromedriver is that each have specific browser options.
Also, the other reason for a driver binary is that Selenium does not have native implementations of the browser events that are part of Internet Explorer, Chrome and Firefox (as of v48 and later).

A logical assumption is that Selenium never had native events for Internet Explorer or Chrome previously and that is why it has been required to use the specific driver binary for each browser type.



What is Automation?


Automation:


In software testing, test automation is the use of special software (separate from the software being tested) to control the execution of tests and the comparison of actual outcomes with predicted outcomes.

Ex: Sending Bank statements to all customers automatically every month Credit Salary for all Employees every month ....etc

Advantages of Automation:

Ø  Fast: Runs tests significantly faster than human users.
Ø  Repeatable: Testers can test how the website or software reacts after repeated execution of the same operation.
Ø  Reusable: Tests can be re-used on different versions of the software.
Ø  Reliable: Tests perform precisely the same operation each time they are run thereby eliminating human error.
Ø  Comprehensive: Testers can build test suites of tests that covers every feature in software software application.
Ø  Programmable: Testers can program sophisticated tests that bring hidden information.

When to go for Automation:

Application should be stable
Stable: Majority of the test cases should be pass and no blocker.