Idea logo

The IntelliJ IDEA Blog

The Capable & Ergonomic Java IDE by JetBrains


Introducing Selenium Support in IntelliJ IDEA

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.

Selenium PluginPlease 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.

New Selenium ProjectIf 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:

Selenium Libraries

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.

Selenium Page ObjectThis also means that you can spot syntax errors in selectors right after making changes:

XPath InspectionAnd of course there is code completion for standard CSS/HTML elements:

CSS Completion

JavaScript language fragments

There are cases when you can’t use Selenium API to test something and you need to use JavaScriptExecutor instead. Just as it does for XPath and CSS fragments, the IDE now provides code insight features for JavaScript that is passed to Selenium:

JavaScript Completion

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:

HTML Tag Name CompletionThe IDE also provides code completion in all places where you need to use CSS properties or HTML attributes:

CSS Property CompletionNote that the enhancements for Selenium APIs mentioned above are supported for Java, Kotlin, and Groovy.

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.

Selenium Grid ConfigurationWe have also added automatic validation for the configuration file using JSON schema:

Selenium Grid Node Configuration

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:

Selenoid Configuration

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:

Navigation to IssuesPlease refer to the documentation of Allure Framework and Serenity BDD to configure the issue tracker URL.

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:

Navigation to Step UsagesThis is supported for both the Allure Framework and Serenity BDD steps.

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:

Navigation to OwnersYou can navigate to usages of @Feature, @Epic, and @Story annotation values with the find usages action similarly to how you navigate to @Owners:

Usages of Features

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:

Selenium StacktraceNow you can easily navigate to where the problem is without diving into the internal details of a framework, and you can check folded calls only if you really need to.

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.

Happy Developing!

Comments below can no longer be edited.

26 Responses to Introducing Selenium Support in IntelliJ IDEA

  1. Avatar

    DileepG says:

    March 19, 2020

    This is a great leap forward, test automation api’s getting mainstream development kind of enhancements

  2. Avatar

    Reece Dunn says:

    March 19, 2020

    Is it possible to make the “XPathView + XSLT” dependency optional, like is done with the CSS and JavaScript integration? Thanks.

    • Avatar

      Yuriy Artamonov says:

      March 20, 2020

      Yes, we can make it optional. Could you please tell us more about your use case?
      Why do you disable “XPathView + XSLT” plugin? It is a quite small plugin that only provides XPath language and XSLT features.

      • Avatar

        Reece Dunn says:

        March 20, 2020

        I have an XQuery plugin that I’m expanding to support XPath. My plugin currently supports XPath 2.0 – 3.1 and vendor extensions (Saxon and MarkLogic) at the syntax level, and am working on adding other features as well, in addition to integrated XSLT functionality and XPath 1.0 support.

        My plugin can co-exist with the “XPathView + XSLT” plugin (in which case it won’t use my XPath language support in XSLT). I would like the ability for my plugin to co-exist with this selenium plugin for users that choose to use my plugin for XPath support (e.g. for MarkLogic based XSLT files), and for me to be able to integrate with the selenium plugin in that case.

        • Avatar

          Yuriy Artamonov says:

          April 15, 2020

          Thanks for the clarification. In 2020.1 release, XPathView is an optional dependency of the Selenium plugin.

  3. Avatar

    Oscar Barrios Torrero says:

    March 19, 2020

    I’m looking forward for exactly that but for Ruby! 🙂

  4. Avatar

    TG says:

    March 20, 2020

    I have problem with find and install Selenium UI Automation plugin. I use IntelliJ IDEA Ultimate but this plugin is not showing in the Plugins Market place, also I try to install plugins manually, but it didn’t installed. How to resolve this problem?

    • Avatar

      Yuriy Artamonov says:

      March 20, 2020

      This plugin is available only for IntelliJ IDEA Ultimate 2020.1 EAP and the upcoming 2020.1 release. It cannot be installed in 2019.3 version.

      • Avatar

        TG says:

        March 21, 2020

        I got it, thank you

  5. Avatar

    Andres says:

    March 20, 2020

    Great new feature to support testing and robust coding!

  6. Avatar

    bgilc says:

    March 20, 2020

    You should also do this for other IDEs. For me PyCharm would be the most important.

  7. Avatar

    Wolfgang Marcos says:

    March 20, 2020

    What is the font used on the code editor?

  8. Avatar

    Michał M says:

    March 20, 2020

    Just noticed that provided example with javascript fragments doesn’t work entirely in Kotlin – it handles one-liners correctly, but everything containing more than one line is ignored – no highlighting and code complete.

    • Avatar

      Yuriy Artamonov says:

      March 21, 2020

      Most likely, you have faced with the .trimIndent() problem. If you remove trimIndent call after string literal all highlighting should work as expected. Please up-vote the following issue if this is your case.

      • Avatar

        Michał M says:

        March 21, 2020

        I’ve also faced that issue with simple string concatenation. E.g.
        Selenide.executeJavaScript(“const className = document.activeElement.className” + “;”)

        • Avatar

          Yuriy Artamonov says:

          March 22, 2020

          Yes, that is a known issue. In practice, you do not need concatenations in Kotlin, because there are multi-line strings with value interpolation, where language injections already work.

  9. Avatar

    Filip says:

    March 23, 2020

    Is it an option to add another testing framework support I’m a member and one of the main maintainer of FluentLenium library, is it an option to help you add the FluentLenium support?

    • Avatar

      Yuriy Artamonov says:

      March 24, 2020

      Thank you for the mention. If there are any OSS projects with big test code-bases based on FluentLenium please share the links, It would help us a lot.

      • Avatar

        Filip says:

        March 31, 2020

        I don’t have any knowledge related to OSS project but I can say complex projects like > 1200 Selenium Scenarios with total execution time (9h) works very well with this library. I was trying to search for FluentLenium in github found something but it is not an answer to your question.

        But I can bring some statistics from Maven Central Nexus Repository

        The number of unique downloads of the library in march was around 60k.

        • Avatar

          Yuriy Artamonov says:

          April 15, 2020

          Thanks, we are planning to include support for FluentLenium in 2020.1.1 – language injections for selectors and library in New Project wizard. Stay tuned!

  10. Avatar

    Gaurav Chaturvedi says:

    April 13, 2020

    Great news to support testing framework in IDE, is there any option to support cucumber and rest assured in near future.

  11. Avatar

    Ilya Sobolev says:

    May 11, 2020

    Seems found a bug in pom generation. In maven-surefire-plugin section missed a “/” symbol between “aspectjweaver” and “${aspectj.version}”.
    That causes: “Error opening zip file or JAR manifest missing : /Users/ilya/.m2/repository/org/aspectj/aspectjweaver1.9.5/aspectjweaver-1.9.5.jar

  12. Avatar

    Pramod Yadav says:

    June 18, 2020

    Very impressive! Both the support for selenium in IntelliJ and the way you guys are taking user feedback and doing a speedy implementation of these requests ( from comments section). Kudos to IntelliJ and Yuriy Artamonov for your awesome support!

Discover more