How to work with the Selenium IntelliJ IDEA plugin

0
7329
3 min read

Most of the framework components you design and build will be customized to your application under test. However, there are many third-party tools and plugins available, which you can use to provide better results processing, reporting, performance, and services to engineers using the framework. In this article, we cover one of the most popular plugins used with Selenium – the Selenium IntelliJ IDEA plugin.

IntelliJ IDEA Selenium plugin

When we covered building page object classes earlier, we discussed how to define the locators on a page for each WebElement or MobileElement using the @findBy annotations. That required the user to use one of the Inspectors or plugins to view the DOM structure and hand-code a robust locator that is cross-platform safe.

Now, when using CSS and XPath locators, the hierarchy of the element can get complex, and there is a greater chance of building invalid locators. So, Perfect Test has come up with a Selenium plugin for the IntelliJ IDEA that will find and create locators on the fly.

Before discussing some of the features of the plugin, let’s review where this is located.


Sample project files

There are instructions on the www.perfect-test.com site for installing the plugin and once that is done, users can create a new project using a sample template, which will auto- generate a series of template files. These files are generic “getting started” files, but you should still follow the structure and design of the framework as outlined in this book.

Here is a quick screenshot of the autogenerated file structure of the sample project:

sample project

Once the plugin is enabled by simply clicking on the Selenium icon in the toolbar, users can use the Code Generate menu features to create code samples, Java methods, getter/setter methods, WebElements, copyrights for files, locators, and so on.

Generating element locators

The plugin has a nice feature for creating WebElement definitions, adding locators of choice, and validating them in the class. It provides a set of tooltips to tell the user what is incorrect in the syntax of the locator, which is helpful when creating CSS and XPath strings.

Here is a screenshot of the locator strategy feature:

locator strategy feature

Once the WebElement structure is built into the page object class, you can capture and verify the locator, and it will indicate an error with a red underline.

When moving over the invalid syntax, it provides a tooltip and a lightbulb icon to the left of it, where users can use features for Check Element Existence on page and Fix Locator Popup. These are very useful for quickly finding syntax errors and defining locators.

Here is a screenshot of the Check Element Existence on page feature:

Check Element Existence

Here is a screenshot of the Fix Locator Popup feature:

Fix Locator Popup feature

The Selenium IntelliJ plugin deals mostly with creating locators and the differences between CSS and XPath syntax. The tool also provides drop-down lists of examples where users can pick and choose how to build the queries. It’s a great way to get started using Selenium to build real page object classes, and it provides a tool to validate complex CSS and XPath structures in locators!

Apart from the Selenium IntelliJ plugin, there are other third-party APIs such as HTML Publisher Plugin, BrowserMob Proxy Plugin, ExtentReports Reporter API and also Sauce Labs Test Cloud services. 

This article is an excerpt taken from the book Selenium Framework Design in Data-Driven Testing by Carl Cocchiaro. It presents a step-by-step approach to design and build a data-driven test framework using Selenium WebDriver, Java, and TestNG.

Selenium Framework Design in Data driven Testing

 

Data Science Enthusiast. A massive science fiction and Manchester United fan. Loves to read, write and listen to music.

LEAVE A REPLY

Please enter your comment!
Please enter your name here