Selenium is a popular framework for testing web applications in the Java world, and we have decided to improve IDE support for selenium-java and its accompanying tools and libraries.
The upcoming IntelliJ IDEA 2020.1 Ultimate introduces initial support for Selenium with a new Selenium UI Automation Testing plugin. The new plugin supports the most popular JVM frameworks for UI testing and reporting libraries: Selenium, Selenide, Geb, Serenity BDD, and Allure Framework.
IntelliJ IDEA’s enhancements for Selenium include a new project wizard, highlighting, inspections and code completion in tests for Java/Kotlin/Groovy languages, validation for various configuration files, and icons in the gutter for easier navigation. Read on for more details about these enhancements, as well as some examples of how they work.
Please note that the Selenium plugin is not bundled, so you’ll need to install the plugin before using this new functionality. Go to Preferences | Plugins | Selenium UI Automation Testing plugin, or download the plugin from the website. The new Selenium plugin is only compatible with IntelliJ IDEA Ultimate.
New project with Selenium and test libraries
Once the Selenium plugin is installed, you can create a UI test project directly from the New Project wizard. The dialog will walk you through the initial configuration, where you can specify the JDK; build tool – Maven or Gradle; test runner – JUnit or TestNG; language – Java, Kotlin, or Groovy; and additional test libraries.
If you prefer using Groovy or Kotlin as your language for UI tests, there are additional helper libraries: Geb and Balin. They become available if you choose the corresponding language in the first step:
XPath and CSS language fragments
Working with XPath and CSS selectors can be challenging, as it requires knowledge of many edge cases and language details. To make your life easier we have added code insight support for XPath and CSS, which are used in Selenium API as well as in many other libraries for UI testing.
Code completion for HTML tags, attributes and CSS properties
There are many ways to obtain WebElements in Selenium, and you may switch between them, by using HTML tag names, for instance:
Code completion and validation for
Selenium Grid 3 configuration
It is not so easy to configure a test environment for Selenium, and the IDE now helps you edit the Selenium Grid 3 configuration files: hubConfig.json and nodeConfig.json.
Code completion and validation for Selenoid configuration
Another popular tool for UI testing with multiple browser versions is Selenoid. When you edit the browsers.json file, you will get code completion and validation by schema that is similar to what you get for Selenium Grid files:
Line markers with navigation to issues and TMS cases in web browser
Tests usually contain links to issue trackers and test management systems, and to make this possible, developers use reporting libraries, such as Allure Framework, or built-in test framework mechanisms, for instance, Serenity BDD. We have added support for the annotations of these libraries, and the IDE can now open issues or TMS cases in a web browser just by clicking on the issue ID:
Line markers with quick navigation to step usages
Step methods are common building blocks of UI tests, and we now provide a quick usages popup for methods with @Step annotations. It contains all usages grouped by origin method:
Find usages and code completion for Allure Framework annotations
There are many useful metadata annotations in modern reporting libraries, for instance the @Lead and @Owner annotations of Allure Framework. The IDE provides code completion for leads and owners already used in the project:
Stacktrace foldings for Run & Debug
Sometimes tests fail and you need to check their stack traces with tons of internal stack frames from different libraries. We have simplified this, and the IDE now hides unnecessary stack frames in folding regions:
We hope you are looking forward to trying out all these new features. Let us know what you think in the comments below or on Twitter.