Page 1 of 2

Checkbox/Checked property not found

Posted: Tue Jan 27, 2015 10:58 pm
by zoework
I was able to write some custom code that will select/skip a checkbox depending on the status during runtime. The problem seems to be that the checkbox is not really seen as a checkbox, but rather as a span item of a multi-select list. Below is my code snippet in C# and I have attached a snapshot of the item in the object repository:
// get status of checkbox
varDateChk = repo.TradeKingLIVE.MultiSelect.Date2.Element.GetAttributeValueText("checked");
// check box if not checked
if(varDateChk == "False") {repo.TradeKingLIVE.MultiSelect.Date2.Click("8;8");}

The second statement works fine, but the first statement doesn't. In the repository I cannot see the 'checked' property at all.

Hope somebody can give me some insight.
Regards,
Zoe

Re: Checkbox/Checked property not found

Posted: Wed Jan 28, 2015 1:00 pm
by Support Team
Hi Zoe,

Which element is the Date2 one, which RxPath do you use for this item?
Have you already tried to use the input element(/dom[@domain='qa.phoenix.tkoffice.com']//div[#'multi-select']/?/?/li[@innertext='Jan 30 2015']/input) instead?

Regards,
Markus

Re: Checkbox/Checked property not found

Posted: Thu Jan 29, 2015 3:35 pm
by zoework
Hello Markus,
The Date2 element in the repository is the name for this XPath:
/dom[@domain='qa.phoenix.tkoffice.com']//div[#'multi-select']/ul/li[@innertext='Jan 30 2015']/label/span
Both label and span highlights the checkbox. The li highlights a rectangle that includes the checkbox and innertext.

I don't understand how to use the input as you mention. I need to get the status of the checkbox in the UserCode if possible. This test works fine without any custom code, but I would like it to be more dynamic, hence the added code.

Re: Checkbox/Checked property not found

Posted: Fri Jan 30, 2015 3:22 pm
by RobinHood42
Hi zoework,

Your code should work when you change "/label/span" to "/input" in the RxPath of your Date2 item, or when you would create a new item, with the RxPath Markus posted, and use this item in your code instead of the Date2 one.

Cheers,
Robin

Re: Checkbox/Checked property not found

Posted: Thu Feb 05, 2015 12:33 pm
by testautomator
User Input tag to get the "Checked" state and user spantag to click on it.
I am guessing Input tag is invisible? If yes, it cannot be clicked.
Also, use inputtag.NextSibling to click on the spantag

Re: Checkbox/Checked property not found

Posted: Thu Feb 05, 2015 4:27 pm
by zoework
Thank you for all the advice. My Ranorex extended evaluation trial expired, but we're currently in the process of buying Ranorex so I will hopefully be able to try out the solutions given here next week. I will post an update as soon as I can.

Re: Checkbox/Checked property not found

Posted: Mon Mar 09, 2015 7:28 pm
by zoework
I've tried to use the Input tag to get the 'checked' value, but every time I edit the Xpath to insert the 'input' property, it cannot find the object anymore.
Here is what I'm trying to do:
Select a date if it has not been selected yet
I have a list of dates (dynamic - they change every week). One of these dates will be selected by default. I need to select the rest of the list.
Any ideas on how to go about it will be welcomed.
Thanks,
Zoƫ

Re: Checkbox/Checked property not found

Posted: Tue Mar 10, 2015 1:57 pm
by RobinHood42
Hello Zoe,

As far as I understood correctly, you want to validate and act based on the "checked"-state of the checkboxes.

In order to iterate over all checkboxes which are stored within the unordered list element you could use the following:
UlTag uList = "/dom[@caption='TradeKing LIVE']//div[#'multi-select']/ul";

var checkboxes = uList.FindDescendants<InputTag>();

foreach(var checkbox in checkboxes)
{
	if(checkbox.Checked == "True")
	{
		//Do something
	}
	else
	{
		//Do something else
	}
}
Hope this helps :D

Cheers,
Robin

Re: Checkbox/Checked property not found

Posted: Fri Mar 13, 2015 7:20 pm
by zoework
Well, I have no idea why this is working now, but it is. I copied the code exactly as given, replaced the //do something with some code and it is working wonderfully.
Thanks for all the help,
Zoe

Re: Checkbox/Checked property not found

Posted: Tue Feb 09, 2016 11:32 pm
by sri
I am having similar issue,in my web based application i dont have Check Box checked property true or false , here i am trying to write a some user code to select all check boxes in a webpage in a loop irrespective of whether it is checked or not,

When i tried to view the check box in object spy it is getting identified as Label without any other attributes and tried many other user codes which didn't work.

Look at the attached screenshots of object spy and application for easy understanding
any help is appreciated

Thank you

Re: Checkbox/Checked property not found

Posted: Wed Feb 10, 2016 8:52 am
by odklizec
Hi,

Apparently, Ranorex identifies that 'checkbox' as label, hence the above suggested code cannot work for you. Could you please post a Ranorex Snaphost (not screenshot) of the element in question? Ideally, please post also the HTML code behind the problematic element. You can easily view it by IE dev. tool invoked by F12.

Re: Checkbox/Checked property not found

Posted: Wed Feb 10, 2016 7:18 pm
by sri
Hi odklizec

Please find the attached snapshot and screenshot .

Thanks

Re: Checkbox/Checked property not found

Posted: Wed Feb 10, 2016 7:19 pm
by sri
snapshot

Re: Checkbox/Checked property not found

Posted: Thu Feb 11, 2016 9:18 am
by odklizec
Hi,

Thanks for the snapshot and HTML source. It helped a lot. The reason why Ranorex picked 'Label' and not checkbox is that the input tag (of type 'checkbox') is from some unknown reason hidden. I would suggest to ask your devs. why, but I guess there is a reason for this? I'm also not exactly sure what is the purpose of 'Label' placed over the checkbox, which seems have attached some script and there seems to be also some script fired on checkbox click event?

Anyway, if you want to enumerate and check all checkboxes, you will have to use this xpath in repository element, which returns all checkboxes you want to check...

Code: Select all

/dom[@domain='localhost']//div[#'grid']/div[@class='k-grid-content']/table/tbody/tr/td/div/input[@id~'gridSelectionCheckbox']
And you will most probably have to click the checkbox, instead of just setting the attribute 'Checked' to true/false.

So the code you are looking for (to check all checkboxes) should look like this:
// Create a list of adapters using the "Info" object  
IList<Ranorex.InputTag> checkboxList = repo.path.to.your.CheckBoxInfo.CreateAdapters<Ranorex.Ranorex.InputTag>();  
foreach (Ranorex.InputTag checkbox in checkboxList)  
{  
    if(checkbox.Checked != "True")  
    {  
    	//click checkbox if not checked (to check it)
    	checkbox.Click();
    }  
}
Hope this helps?

Re: Checkbox/Checked property not found

Posted: Thu Feb 11, 2016 4:33 pm
by sri
Hi odklizec

I have tried the code but I could not succeed in achieving the task as we understood "Input tag" is hidden I guess we cannot make use of it

I have added element to repository based on input tag path "/dom[@path='/Navigator/App' and @domain='localhost']//input[#'gridSelectionCheckbox_0']",

when I tried to highlight the added element from repository it shows following message "The item exists but could not be highlighted because it could not be Made Visible".

I Have used following code but it just click on the header of the page and kept a message to check whether it is going in to the loop and it is going in to the loop.

public void SelectAllChecKBox()
{
IList<Ranorex.InputTag> checkboxList = repo.CallExplorerNavigator.InputCheckBoxInfo.CreateAdapters<Ranorex.InputTag>();
foreach (Ranorex.InputTag checkbox in checkboxList)
{
if(checkbox.Checked != "True")
{
//click checkbox if not checked (to check it)
Report.Info("Am in Loop");
checkbox.Click();

}
}
}