Checkbox/Checked property not found

Ask general questions here.
User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3937
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Checkbox/Checked property not found

Post by odklizec » Thu Feb 11, 2016 5:24 pm

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?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

sri
Posts: 10
Joined: Fri Oct 30, 2015 4:17 pm

Re: Checkbox/Checked property not found

Post by sri » Thu Feb 11, 2016 6:05 pm

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();


}

}
Last edited by sri on Fri Feb 12, 2016 10:12 pm, edited 1 time in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3937
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Checkbox/Checked property not found

Post by odklizec » Fri Feb 12, 2016 8:41 am

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? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

sri
Posts: 10
Joined: Fri Oct 30, 2015 4:17 pm

Re: Checkbox/Checked property not found

Post by sri » Fri Feb 12, 2016 3:41 pm

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
ram

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3937
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Checkbox/Checked property not found

Post by odklizec » Fri Feb 12, 2016 3:50 pm

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']
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

sri
Posts: 10
Joined: Fri Oct 30, 2015 4:17 pm

Re: Checkbox/Checked property not found

Post by sri » Fri Feb 12, 2016 4:59 pm

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']
ram