Forum Discussion

rratchat's avatar
rratchat
New Contributor
2 years ago

Cannot get a dynamic ID by using GetPropertyValue.

I have tried to get a dynamic ID by using GetPropertyValue, but it is not working.

Do you guys have any ideas?

...

let dropdownListBoxObject = screenObject.FindElement("/html/body/div[2]/div/div");
let uniqueId = aqObject.GetPropertyValue(dropdownListBoxObject, "id");
Log.Message("uniqueId: " + uniqueId);

...

 

e.g.

<div id="dx-7594ebcf-7777-3185-0afc-2e5cb15b2189" class="dx-scrollable dx-scrollview dx-visibility-change-handler dx-scrollable-vertical dx-scrollable-simulated dx-list dx-widget dx-collection" role="listbox">

It's always returned me uniqueId: 1.

  • Here's an example,

     

    function w3schools()
    {
        // URL https://www.w3schools.com/html/tryit.asp?filename=tryhtml_id_css
        var page = NameMapping.Sys.browser.Page("https://www.w3schools.com/html/tryit.asp?filename=tryhtml_id_css").Panel("container").Panel("iframecontainer").Panel("iframe").Panel("iframewrapper").Frame("iframeResult");
        var item = page.TextNode("myHeader");
        Log.Message(item.getAttribute("id"));
    }

     

    Use getAttribute() method.

     

    I think GetPropertyValue() is returning this value,

     

2 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Here's an example,

     

    function w3schools()
    {
        // URL https://www.w3schools.com/html/tryit.asp?filename=tryhtml_id_css
        var page = NameMapping.Sys.browser.Page("https://www.w3schools.com/html/tryit.asp?filename=tryhtml_id_css").Panel("container").Panel("iframecontainer").Panel("iframe").Panel("iframewrapper").Frame("iframeResult");
        var item = page.TextNode("myHeader");
        Log.Message(item.getAttribute("id"));
    }

     

    Use getAttribute() method.

     

    I think GetPropertyValue() is returning this value,

     

    • rratchat's avatar
      rratchat
      New Contributor

      You are right! It's working now. Thank you so much.