Store if an attribute of an element exists

Hi,

For my test into Katalon Recorder, I’m trying to save in a variable if an element exists, I’m using the command storeElementPresent which allows to return true or false.

I would like to do the same for an attribute of an element:
//*[@id="cpm-in-progress-pm-tracking-maintenance"]@ng-reflect-digits

I don’t know exactly which command to use for that (I don’t find the same for Attribute).

Could you please help me with that ?

Thanks in advance for your help

1 Like

When you say storeElementPresent do you mean this?

If so, and if I understand you correctly (it sounds like you want to check if an element is present/has an attribute), have you tried:

WebUI.verifyElementHasAttribute(yourTestObject,
    attributeName,
    1,
    FailureHandling.OPTIONAL);

?

Here is link to the documentation

1 Like

Thanks for your reply. Nevertheless I’m using directly Katalon Recorder tool, and this command is not present inside:
image

1 Like

@amadese

Why not you try the storeAttribute command?

ae03363e14c172da4bc4574096c289f398a373d2

1 Like

@kazurayam because if the attribute doesn’t exist, the test fails. Before to test the attribute value, I would like to test if the attribute exists.

1 Like

Then why not you test if the attribute exists using the verifyAttribute command before calling storeAttribute?

1 Like

I tried, but when I use it the result is “could not find the element attribute”. (as with storeAttribute) The result is not saved in a variable

1 Like

When an attribute is NOT present, what sort of “result” do you expect to be saved in a variable?

1 Like

I don’t know Katalon Recorder at all. Katalon tells that Katalon Recorder is a Selenium IDE-compabile alternative. So I searched info about Selenium IDE.

The following link tells that in Selenium IDE you can refer to the built-in statusOK variable to check the result of last-executed command. See

verifyElementPresent (locator)
if | !{!statusOK}
 Click (...)
endIf

I searched but couldn’t find any URL that tells the availiability of statusOK in Katalon Recorder.

@amadese

Do you know if the statusOK variable works in Katalon Recorder as well?

1 Like

Is the attribute only ‘present’ via a shadow / virtual DOM? (e.g. React, AJAX, etc) If so, you may need to first interact with an element, or trigger its visibility in some other way, in order to verify the attributes.

1 Like

Hi @mwarren04011990
Altough i like the sollutions you propose, you should be aware that, the current topic is about Katalon Recorder.

Which is a different animal compared with Katalon Studio.
Have the roots in Selenium IDE and so on (feel free to read lot of debates) but such like:
WebUI.verifyElementHasAttribute(yourTestObject do not apply for this tool.

Cheers!

1 Like

Thanks for letting me know. Ima sit this one out

1 Like

Worry not, this toy is unfamilliar for a lot of good experts here …
I was confused also, plenty of the times.
But yeah, is a totally different toy which need different solutions (mostly it requires JS voodoo)

the code of the toy is here (and is opensourced)

2 Likes