{"id":13624173,"url":"https://github.com/JetBrains/intellij-ui-test-robot","last_synced_at":"2025-04-15T20:33:29.750Z","repository":{"id":36954694,"uuid":"301411608","full_name":"JetBrains/intellij-ui-test-robot","owner":"JetBrains","description":"The library allows you to write and execute UI tests among IntelliJ IDEA. You can test your Plugin.","archived":false,"fork":false,"pushed_at":"2025-03-27T19:37:22.000Z","size":1193,"stargazers_count":119,"open_issues_count":33,"forks_count":35,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-04T20:11:05.448Z","etag":null,"topics":["ide","idea-plugin","intellij","intellij-plugin","java","kotlin","test-automation"],"latest_commit_sha":null,"homepage":"https://jetbrains-platform.slack.com/archives/C026SVA9MMM","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JetBrains.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-05T13:06:13.000Z","updated_at":"2025-03-19T16:49:29.000Z","dependencies_parsed_at":"2024-02-12T16:57:37.342Z","dependency_job_id":"58a7c641-3294-44aa-b07a-6196fde6ad99","html_url":"https://github.com/JetBrains/intellij-ui-test-robot","commit_stats":{"total_commits":574,"total_committers":19,"mean_commits":"30.210526315789473","dds":0.5888501742160279,"last_synced_commit":"f89c6eb1976a10dbb9feff72fcb778716649c8f5"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fintellij-ui-test-robot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fintellij-ui-test-robot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fintellij-ui-test-robot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fintellij-ui-test-robot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JetBrains","download_url":"https://codeload.github.com/JetBrains/intellij-ui-test-robot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249148384,"owners_count":21220523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ide","idea-plugin","intellij","intellij-plugin","java","kotlin","test-automation"],"created_at":"2024-08-01T21:01:39.752Z","updated_at":"2025-04-15T20:33:28.908Z","avatar_url":"https://github.com/JetBrains.png","language":"Kotlin","funding_links":[],"categories":["java","kotlin"],"sub_categories":[],"readme":"![official JetBrains project](https://jb.gg/badges/official.svg)\n\nThis library allows you to write and execute UI tests in IntelliJ IDEA. You can use it to test your plugin.\n\nIf you have any questions, feel free to post them in our [Slack Channel](https://jetbrains-platform.slack.com/archives/C026SVA9MMM).\n\n## Quick Start\n\nThe first thing we need to do is to launch the IDE. Because the `runIdeForUiTests` task is blocking, we can run it as an asynchronous\nprocess:\n\n`./gradlew ui-test-example:clean ui-test-example:runIdeForUiTests \u0026`\n\nNext, we can start the tests. Since they run locally, you need to make sure that the Welcome Frame is visible on the screen:\n\n`./gradlew ui-test-example:test`\n\nAlternatively, you can run all tasks at once with the following command:\n\n`./gradlew ui-test-example:clean ui-test-example:runIdeForUiTests \u0026 ./gradlew ui-test-example:test`\n\n## Remote-Robot\n\nThe Remote-Robot library is inspired by Selenium WebDriver. It supports IntelliJ IDEA since version `2019.2`.\n\n![](docs/simple-schema.png)\n\nIt consists of a `remote-robot` client and a `robot-server` plugin:\n\n* `remote-robot` - is a client (test) side library that is used to send commands to the `robot-server` plugin\n* `robot-server` - is an IDEA plugin that must be run with the plugin you are developing\n\nThe easiest way to start the test system is to execute the `runIdeForUiTests` task (refer to the [Quick Start section](#quick-start) above).\nWhen IDEA is initialized, the `robot-server` plugin starts listening for commands from the UI test client.\n\nThe `remote-robot` library communicates with the `robot-server` plugin via an HTTP protocol. This connection means you can\nlaunch IDEA on remote machines or in Docker containers to check your plugin within different test environments.\n\n### Setup\n\nThe last version of the Remote-Robot is `0.11.23`.\n\nIn the test project:\n\n```groovy\nrepositories {\n    maven { url = \"https://packages.jetbrains.team/maven/p/ij/intellij-dependencies\" }\n}\ndependencies {\n    testImplementation(\"com.intellij.remoterobot:remote-robot:REMOTE-ROBOT_VERSION\")\n}\n```\n\nIn the plugin project:\n\n```groovy\nrunIdeForUiTests {\n    systemProperty \"robot-server.port\", \"8082\" // default port 8580\n}\n\ndownloadRobotServerPlugin {\n    version = REMOTE-ROBOT_VERSION\n}\n```\n\nBy default, the port is set to local, so it cannot be reached from another host. In case you need to make it public, you can\nadd the `robot-server.host.public` system property to the `runIdeForUiTests` task:\n\n```groovy\nrunIdeForUiTests {\n    // ......\n    systemProperty \"robot-server.host.public\", \"true\" // port is public\n}\n```\n\nOf course, you can write UI tests in the plugin project.\n\n### Launching\n\nThere are two ways of launching IDEA and UI tests:\n\n#### Using [IntelliJ gradle plugin](https://github.com/JetBrains/gradle-intellij-plugin)\n\nFirst, we need to launch the IDE. Because the `runIdeForUiTests` task is blocking, we can run it as an asynchronous\nprocess:\n\n`./gradlew ui-test-example:clean ui-test-example:runIdeForUiTests \u0026`\n\nNext, we can start the tests. Since they run locally, you need to make sure that the Welcome Frame is visible on the screen:\n\n`./gradlew ui-test-example:test`\n\nAlternatively, you can run all tasks at once with the following command:\n\n`./gradlew ui-test-example:clean ui-test-example:runIdeForUiTests \u0026 ./gradlew ui-test-example:test`\n\nCheck [this project](ui-test-example) as an example.\n\n#### Using ide-launcher\n\nThe `ide-launcher` library allows us to launch IDEA directly from the test. To use it, we need to add a dependency to our\nproject:\n\n```groovy\ndependencies {\n    testImplementation(\"com.intellij.remoterobot:ide-launcher:REMOTE-ROBOT_VERSION\")\n}\n```\n\nNext, we can use `IdeLauncher` to start IDEA:\n\n```java\nfinal OkHttpClient client=new OkHttpClient();\nfinal IdeDownloader ideDownloader=new IdeDownloader(client);\n     ideaProcess = IdeLauncher.INSTANCE.launchIde(\n     ideDownloader.downloadAndExtract(Ide.IDEA_COMMUNITY, tmpDir),\n     Map.of(\"robot-server.port\",8082),\n     List.of(),\n     List.of(ideDownloader.downloadRobotPlugin(tmpDir), pathToOurPlugin),\n     tmpDir\n);\n```\nCheck [Java](ide-launcher/src/test/java/com/intellij/remoterobot/launcher/LauncherJavaExampleTest.java) and [Kotlin](ide-launcher/src/test/kotlin/com/intellij/remoterobot/launcher/CommandLineProjectTest.kt) examples.\n\n#### Useful launch properties\n\n| Property                               | Value         | Description                                                                                                                                                                                                                           |\n|----------------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| jb.consents.confirmation.enabled       | false         | Disable the consent dialog.                                                                                                                                                                                                           |\n| eap.require.license                    | true          | The EAP version requires license the same way as the Release version. This property helps to [avoid EAP login](https://github.com/JetBrains/intellij-ui-test-robot/tree/master/ui-test-example#how-can-i-switch-off-eap-login) on CI. |\n| ide.mac.message.dialogs.as.sheets      | false         | Disable the Sheet dialogs on Mac, they are not recognized by Java Robot.                                                                                                                                                              |\n| ide.mac.file.chooser.native            | false         | Disable the Mac native file chooser, it is not recognized by Java Robot.                                                                                                                                                              \n| jbScreenMenuBar.enabled + apple.laf.useScreenMenuBar             | false + false | Disable the Mac native menu, it is not recognized by Java Robot.                                                                                                                                                                      \n| idea.trust.all.projects                | true          | Disable the **Trust Project** dialog that appears when the project is opened.                                                                                                                                                         |\n| ide.show.tips.on.startup.default.value | false         | Disable the **Tips Of the Day** dialog on startup.                                                                                                                                                                                    |\n\n### Create RemoteRobot\n\nIn the UI test project:\n\n```java\nRemoteRobot remoteRobot = new RemoteRobot(\"http://127.0.0.1:8082\");\n```\n\n### Searching Components\n\nWe use the [`XPath`](https://www.w3.org/TR/xpath-21/) query language to find components. Once IDEA with `robot-server`\nhas started, you can open the `http://ROBOT-SERVER:PORT` [link](http://127.0.0.1:8082). The page shows the IDEA UI\ncomponents hierarchy in HTML format. You can find the component of interest and write an XPath to it, similar to\nSelenium WebDriver. There is also a simple XPath generator that can help you write and test your XPaths.\n\n![](docs/hierarchy.gif)\n\nFor example:\n\n- Define a locator\n\n```java\nLocator loginToGitHubLocator = byXpath(\"//div[@class='MainButton' and @text='Log in to GitHub...']\");\n```\n\n- Find one component\n\n```java\nComponentFixture loginToGitHub = remoteRobot.find(ComponentFixture.class,loginToGitHubLocator);\n```\n\n- Find many components\n\n```java\nList\u003cContainterFixture\u003e dialogs = remoteRobot.findAll(\n    ComponentFixture.class,\n    byXpath(\"//div[@class='MyDialog']\")\n);\n```\n\n### Fixtures\n\nFixtures support the `PageObject` pattern. There are two basic fixtures:\n\n- `ComponentFixture` is the simplest representation of any real component with basic methods\n- `ContainerFixture` extends `ComponentFixture` and allows searching other components within it\n\nYou can create your own fixtures:\n\n```java\n\n@DefaultXpath(by = \"FlatWelcomeFrame type\", xpath = \"//div[@class='FlatWelcomeFrame']\")\n@FixtureName(name = \"Welcome Frame\")\npublic class WelcomeFrameFixture extends ContainerFixture {\n    public WelcomeFrameFixture(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {\n        super(remoteRobot, remoteComponent);\n    }\n\n    // Create New Project \n    public ComponentFixture createNewProjectLink() {\n        return find(ComponentFixture.class, byXpath(\"//div[@text='Create New Project' and @class='ActionLink']\"));\n    }\n\n    // Import Project\n    public ComponentFixture importProjectLink() {\n        return find(ComponentFixture.class, byXpath(\"//div[@text='Import Project' and @class='ActionLink']\"));\n    }\n}\n```\n\n```java\n// find the custom fixture by its default XPath\nWelcomeFrameFixture welcomeFrame=remoteRobot.find(WelcomeFrameFixture.class);\nwelcomeFrame.createNewProjectLink().click();\n```\n\n### Remote-Fixtures\n\nWe have prepared some basic fixtures:\n\n```groovy\ndependencies {\n    testImplementation(\"com.intellij.remoterobot:remote-fixtures:REMOTE-ROBOT_VERSION\")\n}\n```\n\nThe library contains fixtures for most basic UI components. Please check [this package](https://github.com/JetBrains/intellij-ui-test-robot/tree/master/remote-fixtures/src/main/kotlin/com/intellij/remoterobot/fixtures)\nto learn more. In case you want to add missing basic fixtures, you are welcome to PR or create\nan [issue](https://github.com/JetBrains/intellij-ui-test-robot/issues).\n\n### Getting Data From a Real Component\n\nWe use the JavaScript [`rhino`](https://github.com/mozilla/rhino) engine to work with components on the IDEA side.\n\nFor example, retrieving text from the `ActionLink` component:\n\n```java\npublic class ActionLinkFixture extends ComponentFixture {\n    public ActionLinkFixture(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {\n        super(remoteRobot, remoteComponent);\n    }\n\n    public String text() {\n        return callJs(\"component.getText();\");\n    }\n}\n```\n\nWe can retrieve data using `RemoteRobot` with the `callJs` method. In this case, there is a `robot` var in the context\nof JavaScript execution. The `robot` is an instance of extending\nthe [`org.assertj.swing.core.Robot`](https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/core/Robot.html)\nclass.\n\nWhen you use the `callJs()` method of a `fixture` object, the `component` argument represents the actual UI component\nfound (see [Searching Components](#searching-components)) and used to initialize the `ComponentFixture`.\n\nThe `runJs` method works the same way without any return value:\n\n```java\npublic void click() {\n    runJs(\"const offset = component.getHeight()/2;\"+\n        \"robot.click(\"+\n        \"component, \"+\n        \"new Point(offset, offset), \"+\n        \"MouseButton.LEFT_BUTTON, 1);\"\n    );\n}\n```\n\nWe import some packages to the context before the script is executed:\n\n```java\n java.awt\n org.assertj.swing.core\n org.assertj.swing.fixture\n```\n\nYou can add other packages or classes with\njs [methods](https://www-archive.mozilla.org/rhino/apidocs/org/mozilla/javascript/importertoplevel):\n\n```java\nimportClass(java.io.File);\nimportPackage(java.io);\n```\n\nAlternatively, you can just use the full path:\n\n```java\nBoolean isDumbMode=ideaFtame.callJs(\n    \"com.intellij.openapi.project.DumbService.isDumb(component.project);\"\n);\n```\n\n#### Store data between `runJs/callJs` requests\n\nThere are `global` and `local` `Map\u003cString, Object\u003e` variables available in the js context:\n- `global` is a single map for the whole IDE\n- `local` map is defined on a per-fixture basis\n\nPlease check [GlobalAndLocalMapExamples](/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/GlobalAndLocalMapExamplesTest.kt) for additional information.\n\nIn case you made robot-server-plugin port public, you may want to enable encryption for JavaScript code:\n\n```groovy\nrunIdeForUiTests {\n    systemProperty \"robot.encryption.enabled\", \"true\"\n    systemProperty \"robot.encryption.password\", \"secret\"\n}\n\ntest {\n    systemProperty \"robot.encryption.password\", \"secret\"\n}\n```\n\n### Text\n\nSometimes, you may not want to dig through the whole component to determine which field contains the text you need to\nreach. If you need to check whether some text is present on the component or you need to click the text, you can\nuse `fixture` methods:\n\n```java\nwelcomeFrame.findText(\"Create New Project\").click();\nassert(welcomeFrame.hasText(startsWith(\"Version 20\")));\nList\u003cString\u003e renderedText=welcomeFrame.findAllText()\n    .stream()\n    .map(RemoteText::getText)\n    .collect(Collectors.toList());\n```\n\nInstead of looking for the text inside the component structure, we render it on a fake `Graphics` to collect text data and\nits points.\n\n### Screenshots\n\nThere are two ways to get a screenshot.\n\n1. Get a screenshot of the whole screen (method of `RemoteRobot` object).\n\n```java\nremoteRobot.getScreenshot()\n```\n\n2. Get component screenshot (method of `Fixture` object).\u003cbr\u003e\n   The `isPaintingMode` parameter allows you to return a new render of the component (set to `false` by default).\u003cbr\u003e\n   This might be helpful when you don't have a complete set of desktop environments or when any other component covers the\n   component of your interest.\n\n```java\nsomeFixture.getScreenshot();\nsomeFixture.getScreenshot(true);\n```\n\nIn both cases, you will get the `BufferedImage` object specified as `.png`.\n\n### Kotlin\n\nIf you are familiar with Kotlin, please take a look at\nthe [kotlin example](/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/CreateCommandLineKotlinTest.kt). You may find it easier to read and use.\n\n### Steps Logging\n\nWe use the `step` wrapper method to make test logs easy to read. The `StepLogger` example shows how useful it can be.\nFor instance, by implementing your own `StepProcessor`, you can extend the steps workflow and connect to\nthe [allure report](https://docs.qameta.io/allure/) framework.\n\n### FAQ\n\n[FAQ](/ui-test-example)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetBrains%2Fintellij-ui-test-robot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJetBrains%2Fintellij-ui-test-robot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetBrains%2Fintellij-ui-test-robot/lists"}