Dropdown XPath Issue


#1

Hello

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?

Thanks


Use case doubt - OCR
#2

@goncalo_vascbE
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.


#3

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.


#4

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.

aria-label

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


#5

@ashapkina

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


#6

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


#7

Worked perfectly!

Thank you


#8

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


#9

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.


#10

Hello
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?

Thanks


#11

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


#12

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.


#13

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


#14

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