Checkbox/Checked property not found
Checkbox/Checked property not found
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
// 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)
Zoë (aka zoework)
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Checkbox/Checked property not found
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
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
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.
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)
Zoë (aka zoework)
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: Checkbox/Checked property not found
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
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
- testautomator
- Posts: 67
- Joined: Fri Oct 25, 2013 6:37 am
- Location: Bangalore, India
Re: Checkbox/Checked property not found
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
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
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)
Zoë (aka zoework)
Re: Checkbox/Checked property not found
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ë
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)
Zoë (aka zoework)
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: Checkbox/Checked property not found
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:
Cheers,
Robin
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

Cheers,
Robin
Re: Checkbox/Checked property not found
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 for all the help,
Zoe
Thanks,
Zoë (aka zoework)
Zoë (aka zoework)
Re: Checkbox/Checked property not found
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
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.
Re: Checkbox/Checked property not found
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.
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 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
Re: Checkbox/Checked property not found
Hi odklizec
Please find the attached snapshot and screenshot .
Thanks
Please find the attached snapshot and screenshot .
Thanks
You do not have the required permissions to view the files attached to this post.
Re: Checkbox/Checked property not found
snapshot
Last edited by sri on Fri Feb 12, 2016 10:14 pm, edited 1 time in total.
ram
Re: Checkbox/Checked property not found
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...
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:
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']
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 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
Re: Checkbox/Checked property not found
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();
}
}
}
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