Skip to main content

Selenium - Basics

Selenium:

Selenium is an open source automated testing Suite for web applications across different browsers and platforms.

Selenium has 4 major components:

  1. Selenium Integrated Development Environment(IDE)
  2. Selenium Remote Control(RC)
  3. Web Driver
  4. Selenium Grid

1. Selenium Integrated Development Environment:

Selenium IDE is the simplest framework in the Selenium Suite and very easiest to learn. It has got record playback and saving tests and inbuilt reporting tool. 


2. Selenium Remote Control:

Selenium RC was the flagship testing framework of the whole Selenium project for a long time.
This is the first automated web testing tool where it allows users to use their programming language they prefer.

RC comes in 2 forms:

2.1 Selenium Server:     
  • Selenium Server receives selenium commands from your program, interprets them and reports  back the results of those running tests.
  • Selenium Core is a Java Script program which executes selenium commands using  browser's built-in Java Script Interpreter.
  • Server receives selenium commands from your program using simple HTTP GET/POST requests.

2.2 Client Libraries:
  • Client libraries which provide the application interface between each programming language and the Selenium RC Server. eg : Python , Java , PHP etc

As of version 2.25.0 RC, it supports following languages
  • Java
  • C#
  • PHP
  • Python
  • Perl 
  • Ruby



3. WebDriver:

WebDriver itself proves it is better than Selenium IDE and RC.
It uses more object oriented approach eg: JsonWire Protocol and unlike RC, it doesn't rely on JavaScript for automation.
It is developed to support dynamic web pages where elements of the page may change without page reloading using AJAX.
Selenium WebDriver makes direct calls to the browser using native browser's support for automation.
RC injected javascript functions into the browser when browser was loaded and used its javascript to drive the AUT within the browser.



4. Selenium Grid:

Selenium Grid is a tool used together with Selenium RC to parallel tests across different machines or same machine but different browsers.
Uses Hub and Node concepts. The hub acts as a central source of selenium commands to each node connected to it.


My Personal Recommendation :

Use Selenium Web Driver for automating web browser operations and use any open source frameworks such as Robot Framework, Jasmine or Cucumber for logging and reporting. 

driver = webdriver.Chrome('path of local chromedriver.exe');



Selenium RC is useful when your test cases are in different machine and your web application is running in a different machine. In that scenario , we can run selenium-server on the hosted machine and consume the url , and can run the test against the url. 

driver = new RemoteWebDriver(new URL('http://172.20.20.39:4444/wd/hub'), capability);

Note: Selenium-Server should be running at 172.20.20.39 server and by default server will be running on port 4444.

Rest all browser session operations are same for both Selenium WebDriver and Selenium RC APIs.



Thank You!
Happy Learning

Comments

Post a Comment

Popular posts from this blog

Kubernetes ETCDCTL

ETCD is a key-value data store for storing kubernetes state and objects. ETCDCTL is the tool used to back up with snapshot. ETCDCTL a command line tool for interacting with the etcd server  Key Features:  Keep the event history until compaction. access to old version of keys. user controlled key compaction. Support range query. pagination support with limit argument. support consistency guarantee across multiple queries. Replace TTL key with lease. Support watch feature. ETCDTOOL Installation: Build binary from source code  Download tool directly  Build binary from source code: Checkout the code repository git clone -b v3.4.16 https://github.com/etcd-io/etcd.git Change directory to etcd cd etcd Run build script ./build The binaries are under the bin directory. exportPATH="$PATH:`pwd`/bin" Check etcd version etcd --version Download ETCD tool directly: kubectl exec -it etcd-docker-desktop -n kube-system -- /bin/bash -c 'ETCDCTL_API=3 /usr/local/bin/etcd --version' | h

Selenium Basic Commands.

Selenium Commands, Packages and Exceptions. Here I have selected few most frequently asked commands in the interview. Recommended way of Importing webdriver from selenium package. from selenium import webdriver. Once webdriver is imported then you are able to access the classes like this webdriver.Firefox webdriver.FirefoxProfile webdriver.Chrome webdriver.ChromeOptions webdriver.Ie webdriver.Opera webdriver.PhantomJS webdriver.Remote webdriver.DesiredCapabilities webdriver.ActionChains webdriver.TouchActions webdriver.Proxy To launch the application URL: driver = webdriver.Chrome driver.get('http://youtube.com') To get URL of the currently loaded page: driver.current_url To close the current window: driver.close() Exceptions in Selenium: Base Exception class: Selenium.common.exceptions selenium.common.exceptions.WebDriverException selenium.common.exceptions.InvalidElementStateException selenium.common.exceptions

Selenium - Architecture

Selenium Architecture: Here, we will learn about the overall selenium architecture. How communication happens from client library to browser and which are all the components involved between them. Architecture compromises of major four components namely Selenium Language Binding JSON Wire Protocol Browser Drivers Real Browsers 1. Selenium Language Binding: Various programming languages provide their own Rest API support for communicating to their respective browser drivers via JSON Wire protocol. python provides 'selenium ' as a client library which has all the rest API i mplementation  for communicating with browser drivers. Selenium is a third party library which does not come in python basic installation.  You need to install it via PIP command : pip install selenium driver = selenium.webdriver.Chrome('location of the chrome driver executable')  Above line returns one chrome browser session , where rest all browser relate