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

Verify CheckBox.isChecked property for the second time

2 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nagaraj
Top achievements
Rank 1
Nagaraj asked on 28 Jun 2013, 09:41 AM
Hi,

Below is the operation which i am trying to automate

1. Get all the content of the grid and searching for a particular text.
a. If the grid contains the text, then i need to Check a corresponding CheckBox of the GridViewRow
b. Else if the grid does not contains the text, then i need to scroll the page down and repeat the opeation till i find the text

2. Once i clicked on the text when i am trying to verify if the CheckBox is Checked or not, i am getting the below exception

"IsChecked = '((ArtOfTest.WebAii.Silverlight.UI.ToggleButton)(_uiElement)).IsChecked' threw an exception of type 'ArtOfTest.WebAii.Silverlight.ExecuteSilverlightCommandException'"

Below mentioned the code which i have used. Let me know how it can be rectified.


FrameworkElement f =
null;
 
FrameworkElement f1 = null;
 
ScrollBar sc = Browser.BrowserApplication.Find.ByName<ScrollBar>("PART_VerticalScrollBar");
 
ISLRepeatButton rp = sc.Find.ByName<SLRepeatButton>("VerticalLargeIncrease");
 
ISLRepeatButton si = sc.Find.ByName<SLRepeatButton>("VerticalSmallIncrease");
 
f = Browser.BrowserApplication.Find.ByName<Grid>("PART_RootPanel");
 
f1 = f.Find.ByType<ScrollContentPresenter>();
 
for (int i = 0; i < 1000; i++)
{
    ISLCheckBox c = null;
 
    FrameworkElement d = null;
 
    try
    {
        d = f1.Find.ByTextContent("Item");
    }
    catch (Exception ce)
    {
        if (ce.Message.Contains("Element Not found"))
        {
            rp.CustomClick(true);
 
            f.Refresh();
 
            continue;
        }
    }
 
    c = d.Parent<XAML.GridViewCell>().Parent<XAML.GridViewRow>().Find.ByName("PART_DataCellsPresenter").Find.ByType<CheckBox>();
 
    if (c.isChecked != true) // but while verifying for the first time i m getting error
{
        c.Click(); // once the CheckBox property is changed, i am unable to retrieve the value of isChecked again
         
        if (c.isChecked != true) // getting exception in this line
        {
            for (int j = 0; j <= 4; j++)
            {
                si.CustomClick(true);
            }
             
            c.Click();
        }
}

    
 
    break;
}

I am blocked because of this issue.

Thanks in advance,
Nagaraj R.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 03 Jul 2013, 07:11 AM
Hi Nagaraj,

I would recommend you to work with the data item bound for the GridViewRow and its property corresponding to the IsChecked state.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Nagaraj
Top achievements
Rank 1
answered on 04 Jul 2013, 12:46 PM
Thanks for the reply. 

Thats working fine. Thanks a lot

Nagaraj R.
Tags
General Discussions
Asked by
Nagaraj
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Nagaraj
Top achievements
Rank 1
Share this question
or