Selenium Webdriver Tutorial Chrome

Selenium Webdriver Handle Firefox Or Chrome Download Popup Jerry Zhao July 6, 2017 2 When you use Firefox to download a zip or pdf file in selenium webdriver automation test scripts, you may find a dialog popup which you can not handle always. This page documents how to start using ChromeDriver for testing your website on desktop (Windows/Mac/Linux). You can also read Getting Started with Android or Getting Started with ChromeOS. ChromeDriver is a separate executable that WebDriver uses to control Chrome.

In Part 1 of this two-part series, we delve into the theory behind Selenium WebDriver and why it's great for cross-browser testing.

Selenium Webdriver Chrome Download

Join the DZone community and get the full member experience.

Join For Free

Selenium is a popular automation testing framework that is primarily used for the cross-browser testing. It is open source and is ideal for automating testing of web applications across different browsers like Firefox, Chrome, Internet Explorer, Microsoft Edge, etc. Selenium has become a renowned framework and is giving stiff competition to other test frameworks like HP QTP (Quick Test Professional) and AKA HP UFT (Unified Functional Testing). This look at Selenium WebDriver will help you develop the basic understanding of the components of the Selenium suite, Selenium WebDriver architecture, and show you how to run automated tests for cross-browser compatibility.

Components of the Selenium Suite

Below are the core components of the Selenium Test Suite

  • Selenium Integrated Development Environment (IDE).
  • Selenium Remote Control (RC).
  • Selenium WebDriver.
  • Selenium Grid.

Selenium Integrated Development Environment (IDE)

The Selenium IDE is a simple Firefox Plugin and it is used to record and playback scripts. However, the Selenium IDE can only be used to write automation scripts for automating testing of simple use cases. The Selenium IDE does not support conditional statements, exception handling, loops, screenshot captures, etc. For automating complex use cases, a majority of developers and testers prefer to opt for Scripting testing instead of Record and Replay testing. The Selenium test suite consists of Selenium Remote Control (RC) or Selenium WebDriver.

Selenium webdriver tutorial chrome version

The Selenium IDE is available for different operating systems, namely Windows, Linux, macOS, etc. The Selenium IDE for Firefox can be downloaded from here.

Selenium Remote Control (RC)

For testing complex scenarios, Selenium Remote Control (RC) can be used. It is based on the client-server model which makes it possible to execute tests on the browser that is controlled by the server. There are client libraries in different programming languages which make it easy for developers to write effective test cases in a programming language in which they are comfortable and have expertise. Since version 2.25.0, RC has supported Java, C#, Python, Perl, Ruby, etc.

Selenium Server is the core component of the Selenium RC. Some of the core features/responsibilities of the Selenium RC are listed below:

  • Contains the core Selenium Framework and it is mainly responsible for injecting the same in the browser [Chrome, Firefox, Internet Explorer, Microsoft Edge, etc.].
  • The client program sends commands to the RC which are then interpreted by the server and then sent to the browser.
  • After execution, the results are sent back to the client.
  • The client and server communicate via the normal mechanism of HTTP GETs and POSTs. Which is well versed with client-server concepts can manage to write test code with Selenium and WebDriver with ease.

As mentioned earlier, the Selenium RC supports different browsers, unlike the Selenium IDE which is only available for Mozilla Firefox. The downside of Selenium RC is that it does not support record ad playback functionalities, which can be vital in the automation of test cases where tasks are repetitive, especially for regression testing. Before executing the tests using Selenium RC, an instance of the Selenium RC Server should be manually invoked and that instance should be running throughout your entire test cycle.

Selenium webdriver tutorial chromebook

Selenium WebDriver

Selenium Webdriver Tutorial Pdf

The Selenium IDE is GUI-based, whereas Selenium RC is a standalone Java program that will allow you to execute HTML test suites. The Selenium WebDriver framework is more widely used when compared to Selenium IDE and Selenium RC. Unlike Selenium RC which is based on the client-server model, the Selenium WebDriver framework is implemented through a browser-specific driver; i.e., each browser will have its corresponding WebDriver application on which the automation testing would be performed.

Thus, Selenium WebDriver directly communicates with the browser due to which it does not require any separate components like the Selenium Server. It supports various languages, such as C#, Ruby, Java, Python, and Perl. Before you go ahead in this Selenium WebDriver tutorial, make sure to download Selenium WebDriver for the browser on which your cross-browser testing is being performed. You can download Selenium WebDriver from the links below:

Firefoxhttps://github.com/mozilla/geckodriver/releases
Chromehttp://chromedriver.chromium.org/downloads
Internet Explorerhttps://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
Microsoft Edgehttps://blogs.windows.com/msedgedev/2015/07/23/bringing-automated-testing-to-microsoft-edge-through-webdriver/

Selenium Grid

Serial testing is fine until you have to test code that is confined to a few browsers, operating systems, or devices. However, the testing methodology would falter once testing has to be formed in an environment that has multiple combinations. This is where parallel testing can be extremely useful since it can accelerate the whole testing process. Parallel testing can allow you to perform a similar test case across different test configurations, simultaneously. You could also simultaneously execute different test cases in the same browser.

Back to the basics. Selenium Grid is mainly used for parallel testing since it helps in running tests on different machines against different browsers and operating systems, simultaneously. It does the job in conjunction with Selenium RC. An example that showcases the usage of Selenium Grid is below:

Selenium WebDriver Architecture

As a part of this Selenium WebDriver tutorial, it is imperative to have a look at the major blocks that comprise the Selenium WebDriver architecture:

  • Selenium Client Libraries
  • JSON Wire Protocol
  • Browser Drivers
  • Browsers

Let’s have a look at each component in more detail.

Selenium Client Libraries

Selenium Webdriver Tutorial Python

As mentioned earlier, developers can use Selenium to write test code in different languages like C#, Java, Python, Perl, etc. The multi-language support is possible due to Selenium Client Libraries or Selenium Language Bindings. For example, if you are writing code in Python, you would require Python client libraries. Selenium Client Drivers for different programming languages can be downloaded from here.

JSON Wire Protocol

JSON (JavaScript Object Notation) Wire Protocol facilitates the transfer of data between the client and server. It is a REST (Representational State Transfer)-based API. Each browser will have its own browser driver.

Browser Drivers

Browser Driver is mainly used for communicating with the browsers. Since the internal logic of the browser and its functionality is not revealed, Browser Driver ensures the necessary layer of ‘encapsulation’ in order to keep execution level details more abstract. Each browser has its corresponding Browser Driver. Please refer to the section titled 'Selenium WebDriver' in this post, which contains information about the location from where you can download the Browser Drivers.

Browsers

Since Browser Drivers are available for popular browsers like Chrome, Firefox, Internet Explorer, Safari, Microsoft Edge, etc., you can use either of them for performing cross-browser testing. It should be noted that you cannot perform cross-browser testing of a website on a browser whose Browser Driver is not publicly available.

That's all for Part 1! Tune back in on Monday when we'll look at the Python code you need to implement Selenium across multiple browers.

Like This Article? Read More From DZone

web dev ,selenium tutorial ,cross-browser testing ,web application testing

Published at DZone with permission of Harshit Paul . See the original article here.

Opinions expressed by DZone contributors are their own.

Selenium is a web automation framework that can be used to automate website testing. Because Selenium starts a webbrowser, it can do any task you would normally do on the web.

Related course
Browser Automation with Python Selenium

Web Driver
To start a web browser, the Selenium module needs a web driver.
Supported browsers are:


  • Chrome

  • Firefox

  • Internet Explorer

  • Safari

  • Opera

  • PhantomJS (invisible)

To start a browser, you will need to corresponding driver. The driver “ChromeDriver” is needed to start Chrome, “FirefoxDriver” for Firefox.
All drivers can be downloaded from: https://docs.seleniumhq.org/download/

Selenium Webdriver Tutorial Chrome

Selenium Webdriver Tutorial Chrome

Example code
Python will start and control the chromium browser using the code below:

Selenium Webdriver Windows 10

You can change the browser using: