Search This Blog

March 5, 2013

MSTR Web Test Automation- one possible way to fix the issue of Dynamic Object ID


On Feb 19, I wrote a post about MSTR web test automation ( Use Telerik Test Studio to do MicroStrategy Web Test Automation successfully ). After that, one interesting challenge comes to me all the time.

I have some tests that need to click the Week/Month/Quarter Buttons in MSTR dashboard. But the tests always fail. After looking into the issue via Telerik Test Studio, I notice that the following yellow part (ID) is changed all the time. If the ID is dynamic, how can the test pass? The automation never clicks those buttons. That can explain why.


    public ArtOfTest.WebAii.Controls.HtmlControls.HtmlInputButton WeekButton
            {
                get
                {
                    return GetHtmlInputButton>("id=mstr262", "|", "tagIndex=input:0");
                }
            }

Is it possible for developers to make ID static for those Buttons? After talking to our developers, they say this is the Object ID and they can’t control it because they are still in development and is changed very often on MSTR side.

After several attempts, here is my solution:

Chrome has a good feature called “Inspect Element” if I do right click on the Week Button. Before clicking the Week button, inspect element features shows “mstr262”. After clicking the Week button, it shows “mstr265” or “mstr268”, or “mstr269”. ID is really dynamic.

Does Telerik support dynamic ID? The answer is using “~” as follows. “~” means contains. What happens if I try ~mstr26? 

    public ArtOfTest.WebAii.Controls.HtmlControls.HtmlInputButton WeekButton
            {
                get
                {
                    return GetHtmlInputButton>("id=~mstr26", "|", "tagIndex=input:0");
                }
            }


After I use the code above and rerun the test, the test really clicks the Week Button. The test passes.

No comments: