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].
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']"));