How to write XPATH to get SCR attribute for an image or all the available image for a particular product on amazon

URL: “https://www.amazon.ae/d/B07PNLMGQH
Trying to extract image urls available on this link.

On Get Element you can increase maxitems to how many images you expect to find.
Then create an xpath that finds all images that matches what your interested in. ( //img )
Inside Get Element you can grab the properties from the properties hash table or image from item.src

[
{
“Selector”: “NM”,
“browser”: “edge”,
“frame”: “-1”,
“url”: “https://www.amazon.ae/d/B07PNLMGQH
},
{
“xpath”: “//img[@class=‘imgTagWrapper’]/@src
}
]
OR
[
{
“Selector”: “NM”,
“browser”: “edge”,
“frame”: “-1”,
“url”: “https://www.amazon.ae/d/B07PNLMGQH
},
{
“xpath”: “//div[@class=‘imgTagWrapper’]/@src
}
]

I have tried with these XPATHs but still having error as failed locating item.

yes, those xpath’s are invalid, they return a property not an element

Then please help me with one example to extract URL.

remove /@src and use item.src to read it

[
{
“Selector”: “NM”,
“browser”: “edge”,
“frame”: “-1”,
“url”: “https://www.amazon.ae/d/B07PNLMGQH
},
{
“xpath”: “//div[@class="imgTagWrapper"]”
}
]

This Xpath is working, and workflow executed successfully but i didn’t get any url in output. you can check in reference picture.

there is no src on a div …

I don’t know what the screenshot is suppose to do/symbolise …
Again, you use xpath to select ELEMENTS not properties
In your first query you are selecting a property that is not valid ( not valid for openrpa since it always expect an html element, it’s valid xpath )
In your next example your selecting a div. But a div is not am image. you need to rewrite your xpath to select an img tag.
If the img tag i direclty under the div you found, this could work
//div[@class=“imgTagWrapper”]/img
or if you know there is only 1 img and it’s not directly under the div, maybe this would work
//div[@class=“imgTagWrapper”]//img

Thank you so much Allan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.