List box item is not get selected while play back the recorded script in Coded UI Test

Locked List box item is not get selected while play back the recorded script in Coded UI Test

  • Thursday, February 23, 2012 7:39 AM
     
     

    One of My Project, Its a simple select drop downlist "<select></select>" but the content / listitems for the dropdown will be getting populated via AJAX. Here while iam recording i have selected "Region C" and its get recorded successfully. But if play back the recorded script,  it seems not selected the "Region C".Can you please help me on this stuck.

    • Moved by lucy-liu Friday, February 24, 2012 8:52 AM it is a ui test issue (From:Visual Studio Editor)
    •  

All Replies

  • Friday, February 24, 2012 8:50 AM
     
     
    Hi rajatester,
    This issue is about UI test, I will move it to Coded UI test forum for a better support.
    Thank you for your understanding!

    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

  • Friday, February 24, 2012 9:31 AM
    Moderator
     
     

    Hi rajatester,

    Would you mind providing detailed information? Which app are you testing?

    We need to make sure that whether it supports the Coded UI tests, check it from Supported Configurations
    and Platforms for Coded UI Tests and Action Recordings
    .

    If it can use coded UI tests, did you get any error message when you play back the recorded script? If it has, please share it to us. I think we will get more useful information from the error message.

    Best Regards,



    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, February 27, 2012 10:20 AM
    Moderator
     
     

    Hi rajatester,

    Would you mind letting us know the result of the suggestion?

    Have you solved this issue?

    If not, please let us know the latest news about this issue.

    Thank you for your understanding!



    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

  • Tuesday, March 20, 2012 5:35 AM
     
     

    Jack,

    While recording the script manually we were able to select the Region. please refer the below screen shot

    But while play back the script, system is not highlighted the above selected region. Please refer the below screen shot

    Actual Code :- uISelectForRegion27List.SelectedItemsAsString = this.RecordedMethod1Params.UISelectForRegion27ListSelectedItemsAsString;

    "this.RecordedMethod1Params.UISelectForRegion27ListSelectedItemsAsString"-> System is displayed the Value as "Region B".

    But in the left hand side (''uISelectForRegion27List.SelectedItemsAsString = "" ) -> Value is not assigned to this variable. Since its displaying as Blank.

    I don't know why the value is not assigned to that variable as 'Region B".

    I hope you  understand my query and let me know your thoughts.

  • Tuesday, March 20, 2012 10:48 PM
     
     Answered Has Code

    Hi,

    I hope the following code snippet will help you resolve your issue:

            [TestMethod]
            public void Search()
            {
                BrowserWindow bwindow = BrowserWindow.Launch("http://Your_URL_Here");
    
                HtmlHyperlink searchLink = new HtmlHyperlink(bwindow);
                searchLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Advanced Search", PropertyExpressionOperator.Contains);
                Mouse.Click(searchLink);
    
                HtmlRadioButton region = new HtmlRadioButton(bwindow);
                region.SearchProperties.Add(HtmlRadioButton.PropertyNames.Name, "correctAnswer", HtmlRadioButton.PropertyNames.Value, "2");
                region.Selected = true;
    
                HtmlList list = new HtmlList(bwindow);
                list.SearchProperties.Add(HtmlList.PropertyNames.Id, "selectForRegion27", HtmlList.PropertyNames.Name, "selectForRegion27");
                list.DrawHighlight();
    
                string listItemText = "Region A";
                HtmlListItem listItem = new HtmlListItem(list);
                listItem.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
                listItem.SearchProperties.Add(HtmlListItem.PropertyNames.InnerText, listItemText, PropertyExpressionOperator.Contains);
                listItem.DrawHighlight();
    
                listItemText = "Region B";
                listItem.SearchProperties.Add(HtmlListItem.PropertyNames.InnerText, listItemText, PropertyExpressionOperator.Contains);
                listItem.DrawHighlight();
    
                listItemText = "Region C";
                listItem.SearchProperties.Add(HtmlListItem.PropertyNames.InnerText, listItemText, PropertyExpressionOperator.Contains);
                listItem.DrawHighlight();
            }

    You can use the same code to perform the desired action on the list-items. If the list items are dynamic then you can use the index values instead of the innertext (if you do not know the text in advance).

    Please let us know if this does or does not resolve your problem.

    Regards,

    Pankaj

  • Thursday, March 22, 2012 7:22 AM
    Moderator
     
     

    Thanks for Pankaj’s help.

    Hi rajatester,

    Any update? Could you get useful information from Pankaj’s reply?

    Would you mind letting us know the result of the suggestion? If still no help, can you share us the error message when you run the coded UI test?

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, April 09, 2012 5:17 AM
     
     

    Hi Pankaj &Jack,

    I tried with Pankajs' script but still its not selected the "Region C". One more thing is that system will not throw error message and even when i play back the  recorded script too. Because its search functionality means that, it will throw alert message like there is no record found. Please let me know if you find solution for my query.

    thanks,

    Rajasekaran

  • Monday, April 16, 2012 3:01 AM
     
     

    Hi Jack,

    I have the same problem with HtmlRadioButton and have 2 issues with it:

    One:
     When I recorded, I was able to capture the object (control), but the scipt could not select the radio button in the playback.

    Second:
    The value of this radio button is dynamic and changes from one environment to another. for example, if I open the webpage in QA  the radio button has a different value than that of Staging.

    if you can please provide me with solution for both scenarios 

     public HtmlRadioButton UIIDradioRadioButton
            {
                get
                {
                    if ((this.mUIIDradioRadioButton == null))
                    {
                        this.mUIIDradioRadioButton = new HtmlRadioButton(this);
                        #region Search Criteria
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.Id] = null;
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.Name] = "IDradio";
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.Value] = "100449";
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.LabeledBy] = null;
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.Title] = null;
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.ItemCount] = "10";
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.Class] = null;
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.ControlDefinition] = "onclick=\"selectID(1,\'Sam Money\', \'";
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.TagInstance] = "3";
                        this.mUIIDradioRadioButton.WindowTitles.Add("Search Account");
                        #endregion
                    }
                    return this.mUIIDradioRadioButton;
                }
            }

  • Monday, April 16, 2012 9:15 AM
     
     

    Hi,

    Rajatester: The code worked fine for me. Please let us know if there is anything specific that I might have missed out. Also explain with a scenario how you intend to handle the alert.

    Jordan: You can try to find out the immediate parent of radio button and use it as the container. Or if there is a label associated with the radio buttons you can use it to reach the specific radio button. If you need an example, please share the html page (screenshot and page-source).

    Regards,

    Pankaj

  • Tuesday, April 17, 2012 4:02 AM
     
     

    Hi Team,

    I have mentioned the URl " "http://www.sellbuytheroom.com/Search" for your reference that i am facing the above mentioned Issue.

    Please let me know your thoughts.

    thanks!

    Rajasekaran

  • Tuesday, April 17, 2012 8:20 AM
     
     

    Hi Rajasekran,

    I had tested the provided code on the url visible in the screenshots provided by you. Please give the exact steps that you want to perform (Test cases). I will try my hands on it today evening and get back if I get any solution.

    Regards,

    Pankaj


    Utility to run CUIT Ordered Tests for multiple iterations @ http://cuitbatchrunner.codeplex.com/

  • Tuesday, May 15, 2012 6:00 AM
     
     

    Pankaj,

    Created a New Item and activate the Item. Searching for the newly created Item in the Advanced search page with specific search(Select the region).

  • Tuesday, May 15, 2012 10:32 AM
     
     

    Hi,

    Please find the VB code below: (Launch Site and Select Region radio button and run the below code)

    Dim win As WinControls.WinWindow = New WinControls.WinWindow()
    win.SearchProperties.Add("Name", "SellBUYtheroom.com - An Online Auction Website - Windows Internet Explorer")
    Dim lstItm As WinControls.WinListItem = New WinControls.WinListItem(win)
    lstItm.SearchProperties.Add("Name", "West")
    Mouse.Click(lstItm)

    Thanks,

    Ramaraju