JetBrains / intellij-ui-test-robot

The library allows you to write and execute UI tests among IntelliJ IDEA. You can test your Plugin.

Home Page:https://jetbrains-platform.slack.com/archives/C026SVA9MMM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ComponentLookupException while trying to access ComboBox using build in fixture

zcervink opened this issue · comments

Code that throws ComponentLookupException:
ComponentFixture projectJdkComboBox = comboBox(byXpath("//div[@accessiblename='Project SDK:' and @class='JPanel']"), Duration.ofSeconds(10));

Code that also throws the same ComponentLookupException:
ComboBoxFixture projectJdkComboBox = findAll(ComboBoxFixture.class, byXpath("//div[@accessiblename='Project SDK:' and @class='JPanel']")).get(0);

Code that works:
ComponentFixture projectJdkComboBox = findAll(ComponentFixture.class, byXpath("//div[@accessiblename='Project SDK:' and @class='JPanel']")).get(0);

Error msg details:
Wrapped org.assertj.swing.exception.ComponentLookupException: Unable to find component using matcher org.assertj.swing.core.NameMatcher[name='javax.swing.JPanel[,91,5,491x30,layout=java.awt.GridBagLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]', type=javax.swing.JComboBox, requireShowing=true].

Snímek obrazovky 2021-10-02 v 19 43 47

Thanks for the issue! The problem here is that when you want to use ComboBoxFixture you have to define a locator to the Combobox component instead of JPanel in your example. When ComboboxFixture is initialized it creates a custom CellReader to be able to read text in its items which is not applieble for JPanel.

So, could you please try this locator?

ComponentFixture projectJdkComboBox = comboBox(byXpath("//div[@accessiblename='Project SDK:' and @class='JPanel']/div[@class='JdkComboBox']"));

@nizienko Thank you very much for help, your locator is working without issue.