This is a migrated thread and some comments may be shown as answers.

Need to do a real click but can't

1 Answer 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 29 May 2013, 10:01 PM

I'm trying to click the check box with record and playback, on play back the system is not invoked.  I'm trying to have it do a real mouse click, any ideas?  I would like the option to select by Text of the check and the item number.

Telerik.WebAii.Controls.Html.RadListBox listBox = ActiveBrowser.Find.ById<Telerik.WebAii.Controls.Html.RadListBox>("ctl00_cphTracerPage_rcmbTracersTemplate");

            foreach (Telerik.WebAii.Controls.Html.RadListBoxItem lbItem  in listBox.Items)

            {

                bItem.ScrollToVisible();

                lbItem.Click();

                lbItem.Select();

                Log.WriteLine("List Item: " + lbItem.ToString());

            }


<div class="RadListBox RadListBox_Office2010Blue RadListBoxScrollable" id="ctl00_cphTracerPage_rcmbTracersTemplate" style="width: 300px; height: 400px;">
<div class="rlbGroup rlbGroupRight">
<ul class="rlbList">
<li class="rlbItem rlbHovered" id="ctl00_cphTracerPage_rcmbTracersTemplate_i0">
<input class="rlbCheck" type="checkbox">
<span class="rlbText">JCR - CT Scan</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i1">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Emergency Management</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i2">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Endoscopy</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i3">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Environment of Care</span>
</li><li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i4">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - EOC Rounds</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i5">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Equipment Cleaning and Low Level Disinfection</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i6">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Human Resources</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i7">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Infection Prevention and Control</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i8">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Infection Prevention/Isolation</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i9">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Information Management</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i10">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Information System-2nd Generation</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i11">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Inpatient Generic Tracer</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i12">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Labor and Delivery</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i13">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Leadership</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i14">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Life Safety</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i15">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Medical Staff</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i16">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Medication Management_v2</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i17">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - MRI</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i18">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - National Patient Safety Goals_v2</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i19">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Nursing_v2</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i20">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Outpatient Clinic</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i21">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Pain Assessment-Reassessment</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i22">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Pain Management</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i23">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Patient Flow</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i24">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Performance Improvement</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i25">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Phlebotomy Observation</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i26">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Provision of Care_v2</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i27">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Radiology</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i28">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Record of Care</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i29">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Rights and Responsibilities of Individuals</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i30">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Surgical Patient</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i31">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Tissue Management</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i32">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Transplant Safety</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i33">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Ultrasound</span></li>
<li class="rlbItem" id="ctl00_cphTracerPage_rcmbTracersTemplate_i34">
<input class="rlbCheck" type="checkbox"><span class="rlbText">JCR - Waived Testing</span></li>
</ul></div>
<input name="ctl00_cphTracerPage_rcmbTracersTemplate_ClientState" id="ctl00_cphTracerPage_rcmbTracersTemplate_ClientState" type="hidden" value='{"isEnabled":true,"logEntries":[],"selectedIndices":[],"checkedIndices":[],"scrollPosition":0}' autocomplete="off">
</div>
 
             

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 30 May 2013, 04:02 PM
Hello John,

If you want to click on all CheckBox elements and log the content of all ListBox items, use the following code:
Telerik.WebAii.Controls.Html.RadListBox listBox = ActiveBrowser.Find.ById<Telerik.WebAii.Controls.Html.RadListBox>("ctl00_cphTracerPage_rcmbTracersTemplate");
Assert.IsNotNull(listBox);
 
foreach (Telerik.WebAii.Controls.Html.RadListBoxItem lbItem in listBox.Items)
{
    lbItem.ScrollToVisible();
 
    //Click on all checkboxes
    lbItem.Find.ByAttributes<HtmlInputCheckBox>("class=rlbCheck").MouseClick(); 
 
    //Log the text of all items
    Log.WriteLine("List Item: " + lbItem.BaseElement.InnerText);
}

If you simply want to check a specific CheckBox based on the text content of the ListBox item, use the following code instead:
Telerik.WebAii.Controls.Html.RadListBox listBox = ActiveBrowser.Find.ById<Telerik.WebAii.Controls.Html.RadListBox>("ctl00_cphTracerPage_rcmbTracersTemplate");
Assert.IsNotNull(listBox);
 
foreach (Telerik.WebAii.Controls.Html.RadListBoxItem lbItem in listBox.Items)
{
    if (lbItem.BaseElement.InnerText == "JCR - Life Safety")
    {
        lbItem.ScrollToVisible();
 
        //Click on all checkboxes
        lbItem.Find.ByAttributes<HtmlInputCheckBox>("class=rlbCheck").MouseClick();
 
        //Log the text of all items
        Log.WriteLine("List Item: " + lbItem.BaseElement.InnerText);
    }
}

See this video for a quick demonstration of the above code samples and let me know if you need further assistance on this.

Regards,
Plamen
Telerik
Free summer webinars on advanced web automation tactics hosted by Jim Holmes & Adam Goucher.
Reserve your seat today!
Tags
General Discussions
Asked by
John
Top achievements
Rank 2
Answers by
Plamen
Telerik team
Share this question
or