Checkbox/Checked property not found

Ask general questions here.
zoework
Posts: 38
Joined: Tue Jan 27, 2015 10:44 pm
Location: Charlotte, NC, USA

Checkbox/Checked property not found

Post by zoework » Tue Jan 27, 2015 10:58 pm

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
You do not have the required permissions to view the files attached to this post.
Thanks,
Zoë (aka zoework)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Checkbox/Checked property not found

Post by Support Team » Wed Jan 28, 2015 1:00 pm

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

zoework
Posts: 38
Joined: Tue Jan 27, 2015 10:44 pm
Location: Charlotte, NC, USA

Re: Checkbox/Checked property not found

Post by zoework » Thu Jan 29, 2015 3:35 pm

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.
Thanks,
Zoë (aka zoework)

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Checkbox/Checked property not found

Post by RobinHood42 » Fri Jan 30, 2015 3:22 pm

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

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Checkbox/Checked property not found

Post by testautomator » Thu Feb 05, 2015 12:33 pm

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

zoework
Posts: 38
Joined: Tue Jan 27, 2015 10:44 pm
Location: Charlotte, NC, USA

Re: Checkbox/Checked property not found

Post by zoework » Thu Feb 05, 2015 4:27 pm

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.
Thanks,
Zoë (aka zoework)

zoework
Posts: 38
Joined: Tue Jan 27, 2015 10:44 pm
Location: Charlotte, NC, USA

Re: Checkbox/Checked property not found

Post by zoework » Mon Mar 09, 2015 7:28 pm

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ë
Thanks,
Zoë (aka zoework)

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Checkbox/Checked property not found

Post by RobinHood42 » Tue Mar 10, 2015 1:57 pm

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

zoework
Posts: 38
Joined: Tue Jan 27, 2015 10:44 pm
Location: Charlotte, NC, USA

Re: Checkbox/Checked property not found

Post by zoework » Fri Mar 13, 2015 7:20 pm

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
Thanks,
Zoë (aka zoework)

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

Re: Checkbox/Checked property not found

Post by sri » Tue Feb 09, 2016 11:32 pm

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
You do not have the required permissions to view the files attached to this post.
Last edited by sri on Fri Feb 12, 2016 10:15 pm, edited 1 time in total.

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

Re: Checkbox/Checked property not found

Post by odklizec » Wed Feb 10, 2016 8:52 am

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.
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 » Wed Feb 10, 2016 7:18 pm

Hi odklizec

Please find the attached snapshot and screenshot .

Thanks
You do not have the required permissions to view the files attached to this post.

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

Re: Checkbox/Checked property not found

Post by sri » Wed Feb 10, 2016 7:19 pm

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

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

Re: Checkbox/Checked property not found

Post by odklizec » Thu Feb 11, 2016 9:18 am

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?
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 4:33 pm

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

}
}
}
ram