A possible solution for this could be to find the label control containing the value you are looking to select, then find the child control (which should be the button) then selecting the button.

  String labelToFind = "Senior";
        BrowserWindow  = BrowserWindow.Launch(@"pathToHTMLFile");
        HtmlLabel theLabelToFind = new HtmlLabel();
        theLabelToFind.SearchProperties.Add(HtmlLabel.PropertyNames.InnerText, labelToFind);

        if (theLabelToFind.Exists)
        {
            UITestControlCollection childrenOfLabel = theLabelToFind.GetChildren();
            if (childrenOfLabel.Count >= 1)
            {
                if (childrenOfLabel[0].ControlType.Name == "RadioButton")
                {

                    //can use either one of these two to select the radio button
                    // Mouse.Click(childrenOfLabel[0]);
                    childrenOfLabel[0].SetProperty("Selected", true);
                }
            }

        }

Like you said, another way (and a bit simpler way) could be to just click on the label containing the RadioButton.

        String labelToFind = "Senior";
        BrowserWindow browser = BrowserWindow.Launch(@"pathToHTMLFile");
        HtmlLabel theLabelToFind = new HtmlLabel(browser);
        theLabelToFind.SearchProperties.Add(HtmlLabel.PropertyNames.InnerText, labelToFind);


        if(theLabelToFind.Exists)
        {
            Mouse.Click(theLabelToFind);
        }

Disclaimer: Both of these code examples can be built out to handle more errors and are only proof of concepts.



Source link https://sqa.stackexchange.com/questions/16795/issue-with-radio---in--

LEAVE A REPLY

Please enter your comment!
Please enter your name here