Recent Blogs

Creating a Robot using Java with Selenium to Interact with the Browser

Introduction of Appium in Mobile Automation Test

The way to automate tests or even actions that require access to a web application by a browser is through the use of the Selenium API. That we can perform in conjunction with the Java programming language.

It is based on Java (in addition to other languages) and provides for the development of routines with “step-by-step”. To access a web application, such as login steps, filling out forms, reading the page data, among others. Its versatility also has plug-ins to simulate access by different browsers (Internet Explorer, Firefox, etc.).

The use is spreading in 2 strands, one for tests that simulate behavior closer to the user, validating several ways that a given application can interact with users.

The focus of other aspects of the automation of activities. For example, imagine that there is a test flow that needs to validate if the applications are working. You can develop validation scripts so that they can be periodical.

Throughout this blog, we will explain the basic functioning of this API. And how it can help in automating actions focusing on web applications.

Basic structure

The foundation of Selenium is its component called WebDriver. Through it, it is possible to perform interactions with web applications. You can use standard WebDriver from Firefox, IE, or Chrome, and you can create your WebDriver.

The adaptation of WebDriver for each type of browser is to test and know the behavior in different browsers and rendering the engines. It’s also when we have restricted compatibility to one browser type only.

Step-by-Step Installation

  1. Get the libraries on the http://www.seleniumhq.org/download/ site (Select Java Language and also get the Internet Explorer WebDriver)
  2. Create a new Java project, add a new folder called “lib” and copy all extend files to the jar, including those in the “lib” folder of the compressed Selenium file
  3. Add libraries to the Java Build Path in the Java Build Path command, using project properties>Java Build Path.

Basic Example “Hello World!”

Analyze and verify that the use of Selenium is extremely simple. First, we define WebDriver. From it is configured which URL will be accessed and have the information analyzed. Finally, with a load of data on the page, we will only need to do a simple search to identify whether or not the word is in each of them.

Interaction with web application

The goal is to access a page that has a Calculator in Javascript. And to perform a simple operation to add 1 and 6. Obtaining its result. In this example, we will use the Internet Explorer engine.

With these simple examples, it is already possible to evolve to more complex applications. Either intending to automate actions and tasks or make a testing process increasingly efficient and close to users, simulating a real working condition.

Share this