Problem clicking the button that needs scripting

The problem happens when I click the button but the href is assembled by a script, using the selenium ide inside the test, I can capture this script and the button works but if I use only WebUI.click it does not capture the modification do href, already tried to use the wait but I had no success.
obs: text translated by the translator

It sounds like the href attribute is being accessed instead of the href property.

I will come back with code for you later (I need to leave temporarily).

If anyone wants to jump in in the meantime, please do.

To help you further I will need to see the code you are using.

I did some tests and found that attribute and property assignment behave a little strange which would appear to suggest you may be seeing the same issue in your test case code.

element.setAttribute("href", "value") and element.href = "value" both appear to change the attribute watching them live in the browser console.

However, reading them after they are changed produces different results (which is probably what is causing your issue).

Here is the output from the console looking at the Katalon home page:

As you can see, reading the property results in the fully normalized path whereas reading the attribute reads whatever is assigned by the server (or later changed via code).

Question now is, what is Katalon’s WebUI API reading?

So, if your code is using getAttribute but you’re working with a perspective using the property, you may have unfortunate (but expected) issues.

The solution is likely to be, use a dynamic TestObject (see makeTO), or write the test case step in JavaScript. Either way, post your test case code - that’s the best way to figure out what’s best for your scenario.

@devalex88 @ThanhTo

As you guys know, I’ve griped about this fissure in the WebUI API set before. Regardless of whether the above solves the OP’s issue, as you can see, the debugging proves the current WebUI API set falls short here. We need a properly ratified API set which reflects the Web DOM API set. At the very least we need

  1. https://docs.katalon.com/katalon-studio/docs/webui-get-element-property.html
  2. and webui-set-element-property.html
1 Like

Could you please share the script?

Hi @devalex88

I’m not entirely sure what you’re asking me. The script is pretty much what I used in the browser console, i.e., javascript

Get a property (href) of a dom element:

x = myelement.href;

Get an attribute (href) of a dom element

x = myelement.getAttribute("href");

Setters:

myelement.href = "something";
myelement.setAttribute("href", "something");

I don’t know that your selenium core provides for this - but I see no issue with you using JavaScript directly (i.e. via the core of executeJavaScript API).

My overriding wish is that you provide a new, newly named API set that truly reflects the published DOM API set. I laid it out for you below, with backward compatibility taken care of:

Replied to the wrong post :smile:.

Lol. Now wonder I was confused!

My reply was still a great response though (hint, hint) :wink: :sunglasses: