Selenium Tutorials

If you are a beginner, please Proceed here to start from the beginning.

Upload file using AutoIT

With the help of AutoIt tool (open source tool) we can upload by transferring the control from Selenium webdriver to AutoIt.

We need to explicitly call the AutoIt script from our program.

About AutoIT : AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.

We need to call the AutoIt script after clicking on the upload button. Immediately after clicking on Upload button, the control should be transferred to AutoIt by the below statement which takes care of uploading the file.

Test Configuration File / Executable File

In order to create a test suite and run separate test cases, we need framework which drives the automation. Here testng.xml can be called as "driver" which drives several test cases automated using selenium code.

Advantage of using TestNG with Selenium is of running multiple test cases from multiple classes using xml configuration file

Another advantage of testng.xml is for entire teams that need to share their test configuration or to be able to specify different parameters or subsets of their tests in different testng.xml files

Reporting Structure in Selenium Automation Framework

Reports / Executed Results

Test report/results document which contains summary of test activities performed with pass/fail status and the time taken for execution.

After completing the execution, it is very important to communicate the test results and findings to the project manager and with that decisions can be made for the release.

Test Data in automation framework

Data Set / Test Data

Data set stores the data files, Script reads test data from external data sources and executes test based on it.

Typically the data input can be anything:

  • MS Excel files
  • Data base
  • Text files
  • XML files….etc.

External test data must be easily editable by test engineers without any programming skills. Excel files are the ones that used most often and are familiar with it.

UI Map or Object Repository using Properties File

UI Map / Object Repository

UIMap is a concept for defining, storing, and serving UI elements of an application or a website. The UIMap properties file contains a set of ‘key-value’ pairs, where key is an alias of the UI element, and a value is the locator.

We will create properties file for every single page and capture all the UI elements present on the page and use it as per needs.

UI Map or Object Repository Samples: -

Role - System Admin                                                                                      

Selenium Automation Framework Example

Introduction to Automation testing:

Testing is an essential part of a software development process. While testing intermediate versions of products/projects being developed, testing team needs to execute a number of test cases. In addition, prior to release every new version, it is mandatory that the version is passed through a set of “regression” and “smoke” tests. Most of all such tests are standard for every new version of product/project, and therefore can be automated in order to save human resources and time for executing them.

Set browser width and height in Selenium Webdriver

Selenium WebDriver allows resizing and maximizing window natively from its API. We use 'Dimension' class to resize the window.

Lets take the help of Selenium WebDrivers Dimension Class and declare object say 'd' by initializing it with width and height as 420X600 as shown below:

Remember, We need to import the statement 'import org.openqa.selenium.Dimension'

Handling keyboard events and mouse hover events using Webdriver

In Webdriver, handling keyboard events and mouse events (including actions such as Drag and Drop or clicking multiple elements With Control key) are done using the advanced user interactions API . It contains Actions and Action classes which are needed when performing these events.
In order to perform action events, we need to use org.openqa.selenium.interactions.Actions class.

Here is the sample code to work with Action Class

Webdriver Select with Multiple Attribute

WebDriver’s support classes called “Select”, which provides useful methods for interacting with select options. User can perform operations on a select dropdown and also de-select operation using the below methods.

User can also get the text of the values in the dropdown. Also can get the option which are selected by the user. To use these options, the Select Tag should have "multiple" attribute.