Selenium Testing | Regular Expressions

Selenium Testing | Regular Expressions

Selenium testing is a software testing framework for web applications. Selenium is a strong set of tools that supports quick development of test automation for web-based applications. It was developed in 2004 by Jason Huggins as a JavaScript library used to automate his manual testing routines.

Selenium Core is born whose functionality underlies the Selenium RC (Remote Control) and Selenium IDE tools.The Limitation of having a JavaScript based automation engine and browser security was a drawback of Selenium to specific functionality. Google, was the long time user of Selenium and they had a developer named Simon Stewart who developed WebDriver. This tool evaded Selenium’s JavaScript sandbox to allow it to communicate with the Browser and Operating System directly using native methods.In 2008, Selenium and WebDriver merged technologies and intellectual intelligence to offer the best possible test automation framework.

Selenium provides a set of testing functions specifically geared to the needs of testing of a web application. Selenium operations are highly flexible, allowing many options for placing UI elements and comparing expected test results against actual application behaviour. Components of Selenium are the following:

  • Selenium IDE
  • Selenium Remote Control
  • Selenium Grid

Selenium IDE
Selenium IDE is an integrated development environment for Selenium tests and is implemented as a Firefox extension, and allows you to record, edit, and replay the test in firefox. It allows you to save tests as HTML, Java, Ruby scripts, or any other format and thus allows you to automatically add assertions to all the pages. Selenium IDE allows you to add selenese commands as and when required.

Selenium IDE has some limitations, such as:

  • Selenium IDE can be tested only on Firefox. No Programming login (like loops, conditional statements) can be applied
  • It can execute scripts created in Selenese only.
  • It is hard to use Selenium IDE for checking complex test cases involving dynamic contents.

Selenium Remote control
Selenium remote control is a perfect solution to cross browser testing. It is a server, written in Java and thus available on all the platforms.It also acts as a proxy for web requests from them.Selenium remote control bundles Selenium Core and automatically loads into the browser.

Selenium Grid
Selenium Grid scales the Selenium RC solution for large test suites and test that must be run in multiple environments. It helps to run tests parallel with simultaneous execution (different tests on different remote machines). It permits for running your tests in a distributed test execution environment. It can be used to run your tests against multiple browsers, multiple versions of browser, and browsers running on different operating systems. Selenium Grid takes comparatively less time for the test suite to complete a test pass.

Features
The following are the features of Selenium testing:

  • Selenium testing supports Cross Browser Testing and thus it be run on multiple browsers.
  • It allows scripting in numerous languages like Java, C#, PHP and Python.
  • Its assertion statements give an efficient way of comparing expected and actual results.
  • It has inbuilt reporting mechanism.

Using Selenium as Test Automation tool reduces the cost incurred and also ensures faster delivery. Thus it is cost effective and also not time consuming which proves that this is a standard automation tool for regression.

Of the three type of patterns, Regular Expressions are the one that are the most useful. Selenium supports the complete set of RegEx patterns that Javascript supports. So now you are not limited by the *,? And [] globbing patterns. To use RegEx patterns you need to prefix each RegEx with either regexp: or regexpi:, the latter being case-insensitive.

For example the following will test if a input field with the id ‘name’ contains the string ‘javascript’, ‘JavaScript’ or ‘Javascript’.

Command Target Value
clickAndWait link=search
verifyValue id=name regexp:[Jj]ava([Ss]cript)

Below are a few common regular expression patterns:

regexp:(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d
:match a date in ‘mm/dd/yyyy’ format with any of the ‘-’, ‘/’, ‘.’ as separators.

regexpi:^[A-Z0-9+_.-]+@[A-Z0-9.-]+$
:match a generic email address.

regexp:^[0-9]{5}(?:-[0-9]{4})?$
:match a ZIP code (U.S. postal code), allowing both the five-digit and nine-digit (ZIP + 4) formats.

regexp:^(?!000|666)(?:[0-6][0-9]{2}|7(?:[0-6][0-9]|7[0-2]))-?(?!00)[0-9]{2}-(?!0000)[0-9]{4}$
:match U.S Social Security numbers in the in the AAA-GG-SSSS format.

regexp:^(https?|ftp|file)://.+$
:match almost any url.

Free Selenium Practice Tests | Go To Selenium Practice Test Now

Vskills Certified Selenium Professional Tutorial | Globs
Selenium JavaScript Usage | Selenium Automation Testing Online Course

Get industry recognized certification – Contact us

keyboard_arrow_up