Dropdown XPath Issue


I’m trying to get a value from a web element (Dropdown) from Amazon website and write it on a Notepad.

I’m able to do it with the web element (Departments for ex) but not with the dropdown elements.

Am i doing anything wrong?


I recommend to re-verify your constructed xpath.
(Try to construct the xpath using portable versions of Firefox/Chrome/IE, since the actual execution of the bots happens on those.)

*try to find the xpath with @id attribute for identifying selections in the dropdown list.

I constructed the path using Portable Chrome, still doesn’t recognize the dropdown element.

As for the elements attributes I still didn’t figure out how they work.

For the drop-down elements above, try using xpaths like //*[@id=“nav-flyout-shopAll”]/div[2]/span[1] and attribute aria-label - it contains the text of the drop-down options.


This has to return the value of the aria-label attribute.

1 Like


This is good insight. Thanks
I will utilize this approach in future assignments.

1 Like

If nothing works out, try out image/hotkey/OCR approaches. Such workarounds are robust and reliable.

Worked perfectly!

Thank you

1 Like

But in order to understand this, isn’t the aria-label attribute used for Xpaths that have no visible text?

No, this is only true for this drop-down - I noticed that they have the text in this attribute.
I’m not yet sure why the xpath //*[@id=“nav-flyout-shopAll”]/div[2]/span[1]/span doesn’t return the value, must be because of the page’s structure - we’ll look into it.

1 Like

I’m facing an issue selecting the desired dropdown value. Isn’t the Value Xpath (as showed on the image) supposed to select the value and leave it selected?

Instead it doest the process in the recording, but it doesn’t leave it selected.

Am I missing something?


The first row is successfully selected. When it passes to the second row, it opens the dropdown but changes the dropdown value from the first row.

Since the Xpath’s of the dropdown values are the same, I can understand why that happens.

Is there anyway to specify, for each Xpath, the correct row to select?

This is how I have it:
//select[@id=‘csv_columns_1’] - to select the row
//select[@id=‘csv_columns_1’] - to select the right dropdown value

I was able to do it adding a repeat loop that repeats the down arrow the number of times needed to get the right value, but it’s a slow process. Was hoping there was a faster solution.

Goncalo, are the xpaths the same when you copy them from Chrome, too?

Chrome doesn’t allow me to “Inspect” dropdown values. Only the main element…