Selenium: Lets Talk Selenese – Automation vs. Manual Testing

Let me introduce to you, Jason Huggins! I’m guessing on the exact details of this backstory, so here it goes. It was one of those days, he strolls into work and his boss tells him they just added the “sales” portal to their site for the 3rd attempt. So think about this, Jason has helped to implement, deploy, test, and fall back to the original state… 2 times! Ouch. Another long night again!?

Once again, I’m guessing. After the 2nd attempt, Jason realized that his manual testing processes were too repetitious and inefficient, so he starting writing some words in a document, calling it JavaScriptTestRunner. It was a document that would implement the same testing of functions, elements, and/or objects of the company’s web application in a 1/4 of time it would take to complete manually. In turn, this “script” would save him time and free him up to assist in other areas of the project and he & his team were able to successfully deploy the new sales portal on the 3rd try.

Little did he know that this simple script would revolutionize functional & automation testing. A few years later JavaScriptTestRunner was renamed to Selenium Core and the rest is history.

Automation vs Manual Testing

  • Accuracy
  • Faster Execution
  • Resources
  • Frequency
  • Maintain Core Functions
  • 24-7 Services

Selenium is an open source automation testing tool which is used to execute scripts on web applications (not mobile or desktop applications). It’s open source and mainly used for functional & automation testing.

Have you wanted to know when executing certain steps on a website, how would they look? HUH? How would these steps look inside a JavaScript?

The biggest advantage is Selenium is cross-platform “tool”. It supports various programming languages such as Java, C#, PHP, JavaScript, and Ruby. It supports various operating systems for execution like Windows, Linux, MacOS, etc. and can be used on local devices, cloud services environments and/or onsite selenium Grids. It’s quickly becoming the preferred platform; Quick Test Professional (QTP), IBM RFT and/or CodedUI being their competitors.

How is Selenium is used?

For example, each browser has its own driver for executing the test scripts; for executing Selenium scripts on Chrome, we have Chromedrivers. For IE, we have Internet Explorer drivers. For Safari, we have Safari drivers. For Opera, we have Opera drivers. But only Internet Explorer (IE) and Google Chrome support both the 32bit and 64bit versions.

Selenium has 4 components:

  • Selenium WebDriver (API & preferred portal)
  • Selenium IDE (is a FireFox plugin ONLY)
  • Selenium Grid (Network based)
  • Selenium Remote Control or Selenium 1 (deprecated in v3)

Selenium WebDriver: Enables developers to scale & distribute scripts across many different environments and create browser-based regression automation suites and test cases. Using up to 8 Elements, Object Locators and WD methods or techniques for creation and execution. The WebDriver is the successor to the now-deprecated Selenium Remote Control (coupled with Selenium 1.0); Selenium 1.0 + WebDriver = Selenium 2.0. WebDriver, unlike IDE, is suitable with dynamic/non-static web apps (using xpath functions).

Once you’ve set up your project, Selenium WebDriver functions just like a normal library. It’s self-contained and typically doesn’t require you to start additional processes or run any installers before using it.

  • ChromeDriver – chromedriver.exe
  • Firefox – geckodriver.exe
  • Internet Explorer or Edge – iedriver.exe
  • Opera Driver – operachromiumdriver
  • iOS Driver – iosdriver

Selenium IDE: At Seleniumhq.org/download, this is an Integrated Developer Environment (IDE), written in a language called Selenese, is useful for creating quick bug reproduction scripts, and for exploratory testing aided by automation. This tool will enable you to learn Selenium’s script syntax. The drawbacks: Supports Mozilla Firefox browser only, not suitable with dynamic/non-static web apps, no support custom programming logic scripting.

Most developers get started with Selenium IDE. This helps with gaining familiarity with Selenium commands. Using this IDE, developers can create simple tests rapidly – sometimes within mere seconds. However, Selenium’s developers don’t recommend using Selenium IDE for all testing automation purposes.

Selenium Grid: Used to run multiple test case scripts at the same time on multiple end-node systems (no matter the system/platform being used). Through networking of your systems you can push instructions, etc in-parallel, control different testing scripts through various Operating Systems, Browsers and programming languages.

  • Selenium-server-standalone.jar

Selenium Remote Control: Selenium RC is used to write application tests for different programming languages. It’s communication with web browsers is through the assistance of a Selenium RC Server using HTTP GET/POST requests. The drawbacks: heavy communication paths

Projects In Selenium (a.k.a. Selenium WebDriver)

Selenium WebDriver aims to overcome the limitations of the previous Selenium Remote Control, offering better support for dynamic web pages where the elements on a page are subject to change without the page itself being reloaded. Because a variety of browsers supporting it, Selenium WebDriver uses each browser’s native support for automation. Thus, the features supported and the way that the direct calls are made depends on the web browser that you’re using.

Additionally, the way that you set up a Selenium WebDriver Project depends on both your programming language and your development environment. Another clear advantage & dominance Selenium has over it’s competitors is it’s ability to be set-up using several programming languages:

  • Java: These projects are most easily setup using Maven, which will download Java bindings and all dependencies and create the project for you.
  • C#: C# bindings are distributed as part of a set of signed dlls and dependency dlls. You can download the latest selenium-dotnet zip file here. Then, you’ll need to add a reference to each unzipped dll to your project in whatever IDE you’re using.
  • Python: Run pip install selenium from a command line to add Selenium to a Python environment.
  • Ruby: Run gem install selenium-webdriver from a command line to add Selenium to your Ruby environment.
  • Perl: Bindings for Perl are provided through a third party, such as this example, which offers documentation on getting started.
  • PHP: PHP bindings are also available through third parties
  • JavaScript: The Selenium Project provides JavaScript bindings on npm. Install them by running npm install selenium-webdriver.

Managing Test Cases Using Selenium IDE (Integrated Development Environment)

The Selenium IDE is the tool that you’ll use to develop your test cases. It’s a Firefox plugin that’s intuitive to use, containing a time-saving context menu and Selenium command options that make the process of learning Selenium script syntax simple.

Once you’ve installed Selenium IDE in Firefox, it’s available in the Firefox Tools menu. Selecting it will open a new, empty script-editing window as well as a menu for loading or creating test cases. From there, you can use one of three methods to build test cases (often, you’ll need to use all three):

Recording test cases: This records a test case based on interactions with a website. The record button is on by default when IDE is opened, but you can turn this off in the Options menu. During recording, Selenium automatically inserts commands based on your actions, such as clicking a link (the click or clickAndWait command), entering values (the type command), selecting options from a drop-down menu, or clicking check boxes or radio buttons (the click command).

Adding verifications and asserts: This process enables your test to check the properties of a web page using the assert and verify. To use it, right-click anywhere on the page in the browser displaying your test application and choose from ‘assert and verify options‘ in the context menu. More commands get added to this menu as you continue to use Selenium IDE, which attempts to predict what command and parameters you’ll need for an UI element on a web page. Pure simplicity!

Editing: You’ll also likely encounter the need to edit test cases and manually insert or edit commands and comments. In table view, simply select the point in your test case where you want to insert a command, right-click, and select insert command. Selenium IDE adds a blank line ahead of your selected line where you can use the command editing text fields to enter a new command and its accompanying parameters. In source view, the process is similar: select the point where you want to enter the new command, left-click between the commands in the test pane where you want to enter it, and enter HTML code to create a three-column row with the command, the first parameter (if required), second parameter (if required to locate an element), and third parameter (if required to have a value). You can also enter comments throughout your test cases; these will be ignored when the test case is run.

With Selenium IDE, you can also use a base URL to run test cases in different domains by specifying a relative URL instead of an absolute URL as the argument to open a test case.

To define a test suite, a collection of test cases that you want to run as a continuous batch job, you can use a simple HTML file to define your list of tests. Each row in your HTML file should define the file system path to the tests you want to include in the suite.

Once you’ve mastered the basics of Selenium, you’ll find tons of ways you can put these tools to use to improve your development and testing processes. With many advanced features and functionality, yet being quite simple for beginners to begin using and master, Selenium is a valuable suite of tools for novices and experienced developers alike. The Selenium Wiki on GitHub is a useful source for learning about many advanced capabilities this tool offers. Selenium is a great tool to help with software testing and load testing.

Closing Remarks

You know 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.

As compared to other test automation tools, testing is Selenium’s strongest characteristic. Selenium Suite supports for multiple programming and scripting languages allows a test automation engineer to build any logic to automate testing. WebDriver API is preferred.

Leave a Reply

error: Content is protected !!