Issue with Dynamic ID number changing for combobox in Salesforce

I’m having an issue with Salesforce Combo boxes and the ID changing dynamically almost every time the test runs and opens up the URL. I have also tried using Wait Until Element Is Visible css=button[aria-label=“Category - Current Selection”] timeout=30s getting this: FAIL : Element ‘css=button[aria-label=“Category - Current Selection”]’ not visible after 30 seconds. I’ve even tried Wait Until Element Is Visible css=button[aria-label=“Category - Current Selection: --None–”]

Here is the copy of the element when inspecting:
–None–
Screenshot 2024-04-12 112800

How else can I handle the comboboxes?

@twindecker Is the label preceding or following the combobox unique? Then you can use this label to locate the combobox.

The following XPath’s used to work for me in the past.

XPath to locate the combox would be something like:

//label[normalize-space(text())=‘${comboBoxLabel}’]/following-sibling::div

Where the variable ${comboBoxLabel} contains the visible label text of the combobox.

The XPath to click and open the combobox would be the XPath from above followed by //input
And the Xpath to click on the option within the combobox would be the first Xpath extended with:

//div[@role=‘listbox’]/lightning-base-combobox-item//span[normalize-space(text())=‘${option}’]

Where the variable ${option} contains the visible option text to click on in the combobox.

Thank you Lukas I will give this a try.
When you state "contains the visiable label text of the combobox. You mean this label? not exactly the html code when inspecting the page and element?
image

@twindecker I mean the label Category. So that the XPath for the combobox becomes:

//label[normalize-space(text())=‘Category’]/following-sibling::div//input

1 Like