Verify Element Attribute Value

So i get what you are saying -

When i run the script with the correct values it passes, as i would expect because it has verified that the fields have the correct string and everything checks out, however i cannot prove this because when i try to cross check if it fails it doesnt pick it up. So i think this is where my issue is because i cant be using the VerifyElementAttributeValue correctly otherwise it would be picking up a failure.

All the “evidence” i have is that when running the script - it waits for 20 seconds on the step which should fail, surely this is telling us something ? because if it was set up incorrectly i would have expected it just to pass through immediately like all the others. I added an additional Stop on failure to this step and still nothing.

Truly - im stumped

But yes i agree - if this was an issue there would be alot more topics raised than mine

1 Like

Me too.

But please post back if you find what’s “wrong” – documenting areas of confusion (and their causes) is a “big thing” for me. I spend too much time confused :woozy_face:

1 Like

Let’s have @Brandon_Hein give this a once-over - got good eyes does Brandon.

Cool, thanks - in the mean time ill do some more digging and see if i can see whats wrong. I guarantee it will be the silliest of mistakes thats causing this. Hopefully resolved soon :slight_smile:

1 Like

Can you share the HTML for the <input> element of the field that you are seeing strange behavior for? It would be nice to see both:

  • The HTML for the element when the field is EMPTY.

  • The HTML for the element after a value is entered.

Right so ive found that if i run the script with all the values correct it passes as expected - then if i change the field to “hfhar” instead of test the click run from here for that step it fails and gives me the correct error - so maybe the way im trying to verify it works is not a way you can verify that it works - at this point i think im confusing myself :woozy_face:

Basically to summarise - i now think everything works fine and its just the way i was trying to verify is not a way to do so because im now getting my expected error

Test Cases/touchpoint examples/Create course - HR - 9.1 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify if object 'Object Repository/Create a course/verify course created/input_Administrator_Administra' has attribute 'value' with value 'test' (Root cause: com.kms.katalon.core.exception.StepFailedException: Object 'Object Repository/Create a course/verify course created/input_Administrator_Administra' has attribute 'value' with actual value 'ralliley' instead of expected value 'test')
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementAttributeValueKeyword.verifyElementAttributeValue(VerifyElementAttributeValueKeyword.groovy:109)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementAttributeValueKeyword.execute(VerifyElementAttributeValueKeyword.groovy:70)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementAttributeValue(WebUiBuiltInKeywords.groovy:3234)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementAttributeValue$0.call(Unknown Source)
	at Create course - HR - 9.1.run(Create course - HR - 9.1:78)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.RawTestScriptExecutor.runScript(RawTestScriptExecutor.java:34)
	at com.kms.katalon.core.main.RawTestScriptExecutor.doExecute(RawTestScriptExecutor.java:29)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
	at com.kms.katalon.core.main.TestCaseMain.runTestCaseRawScript(TestCaseMain.java:143)
	at com.kms.katalon.core.main.TestCaseMain$runTestCaseRawScript$0.call(Unknown Source)
	at TempTestCase1551370808363.run(TempTestCase1551370808363.groovy:106)
1 Like

This is with the element populated -

input class="form-control text-box single-line valid" data-val="true" data-val-maxlength="Administrator has a maximum length of 50, please correct before proceeding." data-val-maxlength-max="50" id="AdministratorName" name="AdministratorName" type="text" value="hfarrjdfjas" aria-describedby="AdministratorName-error" aria-invalid="false"

This is the element not populated -

input class=“form-control text-box single-line” data-val=“true” data-val-maxlength=“Administrator has a maximum length of 50, please correct before proceeding.” data-val-maxlength-max=“50” id=“AdministratorName” name=“AdministratorName” type=“text” value=""

Even though i have said i think it is not an issue anymore - i still do not see why what i was trying to do did not work - if you can solve that then perfect

1 Like

And when you type a value into the field, is the DOM updated in real time? In other words, you don’t have to submit the form in some way (like clicking a “Save” or “Submit” button) in order for the value attribute to be updated in the HTML?

So no the DOM isnt updated in real time - i have to click an update button - however i get the error as expected when i change it without clicking update

1 Like

Perfect, then there’s your answer (I think…). You were getting inconsistent/confusing behavior because the value that you were seeing on the screen didn’t necessarily match value of the attribute, depending on whether or not the “update button” was clicked after manipulating the field in some way.

2 Likes

I think your probably right, im going to do a bit more searching before being totally sure but for now, it looks like it works fine - thanks for your help guys @Russ_Thomas @Brandon_Hein :smile:

3 Likes

Right one last thing - this thread will end soon i promise :sweat_smile:

So i might be totally wrong here but im just cross checking something - if you tell me this is wrong then everything works fine and the awnser above is correct but i just want to be 100% sure.

Right - i have changed the elements input to something other than “test” then clicked update, this has updated the DOM - then if i go back into the record and click run from here for the following lines of code

String vcc = 'Create a course/verify course created/'

def to

to = findTestObject(vcc + 'input_Days_k-formatted-value k')
WebUI.verifyElementAttributeValue(to, 'aria-valuenow', '6', 20)

to = findTestObject(vcc + 'input_Code _Code')
WebUI.verifyElementAttributeValue(to, 'value', 'aa booming', 20)

to = findTestObject(vcc + 'input_Administrator_Administra')
WebUI.verifyElementAttributeValue(to, 'value', 'test', 20, FailureHandling.STOP_ON_FAILURE)

to = findTestObject(vcc + 'input_Administrator Job Title_')
WebUI.verifyElementAttributeValue(to, 'value', 'boss', 20)

Surely this should give me an error because the Value as seen in the screenshot is “gfhhg” and not “test”. Im only saying that because the value isnt equal to test, it times for the 20 seconds and moves on. Now like ive said above, it does give me the error without clicking update so this is just me double checking that its working as expected.

1 Like

Treading carefully here… based on what you’ve said, my understanding of what’s going on, limited by my not understanding what was said yesterday (come to that in a moment)… YES.

This talk about clicking the update button (what’s that? save to a database or similar?) which then makes the value populate? What the hell? If that code represents the input element and you’re typing into that same control, then the DOM is “updated” instantly.

If what Brandon said last time out is true, then that means the control you’ve created a TO for, is a different control after submit. Quite why Katalon/Se isn’t complaining about a stale reference I’m not sure.

Then there’s the Katalon/Se “smudging” of the value attr/property. Your screenshot showing the dom explorer… don’t DON’T confuse that (which is showing the actual attribute) with whatever Katalon or your tests are saying the value attribute is. The tools are correct, Katalon/Se are frequently telling little lies.

“What?!!! Surely not!”

It’s true. Katalon tells you the current value of the VALUE PROPERTY. The tool is showing the HTML and therein, the value of the value attribute as supplied by the server when the page was loaded.

The value attribute and the value property are not the same thing.

So showing us evidence from a respectable tool and then comparing its results with those of Katalon/Se is meaningless. At least, no logical progress can be made because of it. Not your fault. Blame Katalon/Se.

Where does that leave us?

I dunno. There’s lots of things I don’t know, this is one of them. :woozy_face:

Like yesterday, I’ll wait for Brandon to take another look. I sure as hell aint getting it.

Rant…
This is why I avoid these Se derived Katalon APIs “mostly”. For this kind of precision, call into JavaScript and use the Web Interfaces (dom APIs) directly. Cut out the middleman, he’s a liar and a cheat and even when he aint, I still don’t trust him.

If you did that, this conversation and all the great times we had together would never have happened :smile:
/Rant

2 Likes

Im glad i didnt do that :rofl:

I was not aware of this and now understand what you are saying - im sure Brandon can clear up the confusion this is causing me and now you :sweat_smile::woozy_face:

At the end of the day it works (…i think) so im just trying to get my head fully around it so i appreciate all your efforts @Russ_Thomas

1 Like

I know. And that’s why I’m staying the course here.

PreachMode
Yesterday I harped on about “try not to fool yourself” and all that good stuff. So today, we can make that a bit more specific: the tools you choose should tell you the truth and be as reliable as you can make them. When the brown smelly stuff hits the whirley thing, clear the decks and go to the source (JavaScript and DOM APIs). The world wouldn’t collapse without Katalon/Se… it sure as hell would without JS/DOM.
/PreachMode

1 Like

Russ, I’m getting more and more convinced your way (JS + DOM) is the way to go. But, the barrier to this is - you need to know JS.

How 'bout you did some tips n tricks post about this topic. For example, how to wait for element clickable using javascript executor or something like that.

Or, here’s one I’m currently struggling with: I have a spinner element (“Please wait while loading”) and I want to wait for it to be invisible. (This is a project I’m working on in Selenium, that’s why I haven’t posted it here before, but I think it could be useful even for Katalon users.) Waiting for the element to be invisible is flaky, i.e. it seems that sometimes I have to wait two times :exploding_head:.

That means:

  • sometimes a wait-for-invisible is correct and I am able to continue with the next step (clicking a button).
  • other times I get the other-element-would-receive-the-click error, and when I put two wait-for-invisible commands in a row, it seems to work fine
  • that makes me think there is something happening in the background (at least two events) that manifests as one event (“Please wait while loading”) in the browser window, but in the DevTools network tab I can see only one GET request

How could you implement this wait with JS? Or find if there are other events firing?