This topic is locked
[SOLVED]

Accessing extended properties of a page object?

2/1/2023 10:09:01 AM
ASPRunner.NET General questions
Pete K author

The Runner JavaScript API exposes many properties of generated page objects, but often I need to do something beyond what is available in the API. Current case in point: I've created a custom button and would like to change the text of the button following a user click. There doesn't seem to be a way to change the Javascript native "textContent" property of a button using the API. So, I tried using straight JavaScript, as in:

document.getElementById(buttonID).textContent = buttonText;

This works, but only if you know the element ID. I naively thought I could examine the source code after a build and use that ID. And it worked when I did the first test. But I discoevered that the ID of a given element can change in successive builds by ASPR.

So my question is, how can I accomplish this? Am I overlooking something obvious? Any guidance would be much appreciated.

—Pete

admin 2/1/2023

Pete,

check this article, it should help:
https://xlinesoft.com/asprunnernet/docs/finditem().htm

Pete K author 2/3/2023

Thank you! You got me on the right track, but at first that didn't work either. Then when I realized the JS code was being applied to the span that wraps the pseudobutton and not to the anchor tag itself, I went back to the API and found getItemButton() which does the same magic for custom buttons. (You probably didn't notice that I was referring to a custom button.)

Thanks for pointing me back to the API -- I should have examined it more closely in the first place.

—Pete