My xpath expressions does not work as expected

Hi, I’ve got really dumb question. I try to use storeAttribute command however always I got an error, no matter how I add my path. With parenthesis or without them. I know that in general parenthesis alone have important role regarding xpath expressions itself and I should not play like that, but until now I did not figured it out where is my mistake.

So below is what I try to execute with an error:

[info] Executing: | storeAttribute | //*[@id=“someID”]/img/@src | test |

[error] Element //*[@id=“someID”]/img/ not found

I’d like to kindly mention that this xpath is correct. How do I know? Well I’ve got legacy Selenium IDE and this command works perfectly fine. Also developer’s tools (inspector) is capable to find out my xpaths. Legacy selenium require to add prefix in parenthesis, so command is a little different:

[info] Executing: | storeAttribute | xpath=(//*[@id=“someID”]/img)/@src | test |

[error] Element //*[@id=“someID”]/img/ not found

Of course very same values does not work with Katalon Recorder as I expected, so my question is:

What the hell is expected form me in Katalon Recorder? How should my xpath looks like? I’ve got hundreds of elements and attributes to work with and not always I can use select target button, I often have to work with xpaths made by me manually.

Hi, for me

storeAttribute | //img/@src | test

work just fine so it’s definitely good construction. Did You try this with diffrent img or diffrent attribute? Did You try this one command without playing whole test?
You can also try stroreValue, for me it’s save src just like storeAttribute
If any of this help you can do this with JS:

runScript | return document.evaluate(“//img/@src”, document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value; | test

The thing is that web page which I work with is pretty complex. It does includes nested iframes, however Katalon Recorder’s does good job regarding that aspect. But I will describe in short what bothers me in this case. So I’ve got multiple iframes, some are nested. Inside them shared code exists, each iframe contains most tags, values and attributes very same as previous one. So I can not simply manipulate with xpaths by by adding number values in square brackets. I have to enter in or out from each iframe and then execute commands which I need and then execute what I do I need. I can not store images by IDs, because they are dynamic, so I have store an attribute after locating my photos using generic xpath expression. And another bummer is there: images are in iframes and html document itself. Images are “hidden” beyond span or div tags, so select target button does not works for me.

I have spent over two years with legacy Selenium IDE, but I’m still on my learning curve. I have an idea to save the page source, remove all divs and spans and hit select target button. But for me this makes no sense at all. I’m pretty certain that images will be stored by IDs, which are dynamic, my xpath expressions have to refer to something else, because I need to get values from IDs. Like I told, I have to store attributes at first, then use my own xpath in order to get job done.

So I wonder how Katalon Recorder generates xpaths, why xpaths created manually by me works with inspector in web browser and legacy Selenium IDE but in Katalon Recorder does not? I may save the source of my page, edit it and publish in order to resolve this case, but I rather prefer to get knowledge about convention which uses Katalon Recorder. This is not only one page which I have to work with.

@Piotr Short answers for your questions:
1/ yes, I did different images and attributes without any positive effect
2/ yes, I gave a try like that, just execute one command. I will include screenshots later on.

As promised, the screenshots included.

Just let me know should I attach source code of the page, which I’m work with. I feel like in case of Katalon Recorder I should enter into iframes at first and then use storeAttribute command in order to work with it. From some reason Legacy Selenium IDE does it without that.

I figured out how to get best possible xpath. In developer tools I decided to remove some obvious tags, attributes and values, so web browser is forced to copy other values than these which are dynamic and I have intention to store them as attributes. That’s the good thing.

Bad thing is that I did not managed how to enter into appropriate iframes and get what I need. After temporary removal of some tags, attributes and values I received xpath with two very same objects in different iframes. In legacy selenium IDE I can not get picture address from appropriate iframe despite the fact that I entered into appropriate iframes. An attribute is stored from first object from top anyway. I can not use square brackets in xpath in order to simply choose another attribute because of these damn iframes I suppose.

It’s bummer but I’m close to figure this out on my own. If I resolve it, I will describe it in this thread. I think that I will play with xpaths further. In source code some tags are different between iframes, so basing upon these differences I have intention to get xpath leading into appropriate attribute.