Page 2 of 2

Re: Checkbox/Checked property not found

Posted: Thu Feb 11, 2016 5:24 pm
by odklizec
Hi,

At first, you can't use unique ID (like this [#'gridSelectionCheckbox_0']) in repo xpath for input, which you want to loop in code. Unique ID means Ranorex will search (and find) just this one particular input, called gridSelectionCheckbox_0. Hence you need to use syntax as per my suggestion [@id~'gridSelectionCheckbox'], which instructs Ranorex to find 'ALL' inputs called gridSelectionCheckbox.

As for the inability to click 'hidden' input, that's true, Ranorex cannot click invisible element. At least not with mouse. It may be possible to "click" it with PerformClick but I'm sure this will not invoke mouse click event and it's generally not recommended to use if testing GUI ;)

What you probably need to do is to use the loop to evaluate the "checked" of input element (even if they are hidden) and if an input is 'unchecked' you should click the associated 'label'. But this is something I'm just guessing. I'm not entirely sure if clicking the label would change the cheked state of underlyig input? This is something you need to discuss with your devs.
Why are the inputs are made invisible? What exactly should be clicked to change the 'checked' state of checkbox?

Re: Checkbox/Checked property not found

Posted: Thu Feb 11, 2016 6:05 pm
by sri
I have tried Performclick it did not work in my case,even in object Spy if checkbox is checked it is checked=True and if not it checked=False,

I have added repository element based on that"/dom[@path='/Navigator/App' and @domain='localhost']//input[@checked='True']"

I think I have to talk to dev regarding the input tag which is hidden!

Please find the attached screenshot of object spy view of input tag


public void SelectAllChecKBox()
{
IList<Ranorex.InputTag> input=repo.CallExplorerNavigator.InputCheckBoxInfo.CreateAdapters<Ranorex.InputTag>();

foreach (Ranorex.InputTag check in input)
{


if(check.Checked!="True")

{
//click checkbox if not checked (to check i
Report.Info("Am in Loop");
check.PerformClick();


}

}

Re: Checkbox/Checked property not found

Posted: Fri Feb 12, 2016 8:41 am
by odklizec
Hi,

Here is somewhat improved code I suggested before...
// Create a list of adapters using the "Info" object    
IList<Ranorex.InputTag> checkboxList = repo.path.to.your.CheckBoxInfo.CreateAdapters<Ranorex.Ranorex.InputTag>();    
bool foundLabel;
Ranorex.LabelTag labelObject;
foreach (Ranorex.InputTag checkbox in checkboxList)    
{    
    if(checkbox.Checked != "True")    
    {    
        //click checkbox if not checked (to check it)  
        foundLabel = checkbox.TryFindSingle<Ranorex.LabelTag>("./../label", 2000, out labelObject);
        labelObject.Click();
    }   
}
Basically, the code search for all 'gridSelectionCheckbox' checkboxes with this xpath (you should have it in repository):
/dom[@domain='localhost']//div[#'grid']/div[@class='k-grid-content']/table/tbody/tr/td/div/input[@id~'gridSelectionCheckbox']
Then it evaluates 'Checked' state of each found checkbox. If there is found an unchecked checkbox, Ranorex then search for 'Label' belonging to the unchecked checkbox and clicks this label.

I'm not quite sure this will help, but it's worth a try? ;)

Re: Checkbox/Checked property not found

Posted: Fri Feb 12, 2016 3:41 pm
by sri
The code you gave me worked to extent! it clicked only on First Row First check Box and stopped and its not clicking on all visible checkboxes.

I have tried using for loop in for each ,but not sure how to use count for all Rows that Exist!
Can u suggest me any further changes in code
Thanks

Re: Checkbox/Checked property not found

Posted: Fri Feb 12, 2016 3:50 pm
by odklizec
Have you changed the repo item xpath to the one I suggested? In one of your previous posts, you mentioned unique ID (#'gridSelectionCheckbox_0'), which could result to the click of just one particular element instead of looping all available checkboxes.

Make sure the repo xpath looks like this:

Code: Select all

/dom[@domain='localhost']//div[#'grid']/div[@class='k-grid-content']/table/tbody/tr/td/div/input[@id~'gridSelectionCheckbox']
Eventually try simpler path like this:

Code: Select all

/dom[@domain='localhost']//div[#'grid']/div[@class='k-grid-content']/table//td//input[@id~'gridSelectionCheckbox']

Re: Checkbox/Checked property not found

Posted: Fri Feb 12, 2016 4:59 pm
by sri
Perfect it worked
Thanks
odklizec wrote:Have you changed the repo item xpath to the one I suggested? In one of your previous posts, you mentioned unique ID (#'gridSelectionCheckbox_0'), which could result to the click of just one particular element instead of looping all available checkboxes.

Make sure the repo xpath looks like this:

Code: Select all

/dom[@domain='localhost']//div[#'grid']/div[@class='k-grid-content']/table/tbody/tr/td/div/input[@id~'gridSelectionCheckbox']
Eventually try simpler path like this:

Code: Select all

/dom[@domain='localhost']//div[#'grid']/div[@class='k-grid-content']/table//td//input[@id~'gridSelectionCheckbox']