Check box based on data connector

Ask general questions here.
dmconsulting1
Posts: 91
Joined: Fri Nov 08, 2019 3:23 pm

Check box based on data connector

Post by dmconsulting1 » Tue Mar 10, 2020 7:50 pm

This might be an easy one, but I am feeling stumped. I have a check box on my app and I want to be able to check or uncheck it based on a data sheet.

What do I need in my Excel sheet to specify Checked/UnCHecked and what action do I call from my recording?

SetValue based on "True"? Invoke Action? Please help.

Thanks.

dmconsulting1
Posts: 91
Joined: Fri Nov 08, 2019 3:23 pm

Re: Check box based on data connector

Post by dmconsulting1 » Tue Mar 10, 2020 9:14 pm

For context the UI has 3 drop down boxes and the one check box. My Excel sheet has the values for each drop down and I use Set Value with the variable for the column. I would like to have a column for the check box, but not sure how to reference it or what action to use for it.

Like an If true = checked.

User avatar
Stub
Posts: 373
Joined: Fri Jul 15, 2016 1:35 pm

Re: Check box based on data connector

Post by Stub » Wed Mar 11, 2020 9:41 am

I do this with various code modules and library code. They take a data source parameter and parse it into a CheckState enum value (Checked, Indeterminate, Unchecked) e.g. a boolean True, Yes, 1, etc can all be converted to Checked.

I then examine the Checkbox control and look at its current state and decide what to do. I might Click or DoubleClick the CheckBox as needed to get the state I'm after. This lets notifications flow through to other elements on the form.

However, I'm thinking you're using recordings, which I don't use, so my mechanism is probably over engineered. It's just something I can re-use in any of my other code modules to reliably get a CheckBox or RadioButton control into the state required. Handling Indeterminate e.g. in a multi-select scenario, was what drove me to generalise this in our test code.

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

Re: Check box based on data connector

Post by odklizec » Wed Mar 11, 2020 11:35 am

Hi,

Could you please post a Ranorex snapshot of the checkbox? It would be much easier to suggest a reliable solution, if we can examine the checkbox. SetValue is good idea, but it may not work in case the checkbox is assigned with onmouse/onclick events? So you should try SetValue and if it works, it's probably the easiest solution. As mentioned, please post the snapshot. Thanks.
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

dmconsulting1
Posts: 91
Joined: Fri Nov 08, 2019 3:23 pm

Re: Check box based on data connector

Post by dmconsulting1 » Wed Mar 11, 2020 2:08 pm

Here is a snapshot of the reorder check box.

Leave it unchecked if the data sheet is blank, checked if true or something?

And what value would I set? "Checked", or from 0 to 1?
Attachments
ReorderCheckBox.rxsnp
(50.57 KiB) Downloaded 4 times

dmconsulting1
Posts: 91
Joined: Fri Nov 08, 2019 3:23 pm

Re: Check box based on data connector

Post by dmconsulting1 » Wed Mar 11, 2020 2:30 pm

Ok, I created a variable called $reorderBeforeVersion with a column in my datasheet.

SetValue of Checked either True or False based on the value in the data sheet. It didn't work. :lol:
checked.png
checked.png (2.63 KiB) Viewed 151 times

User avatar
Stub
Posts: 373
Joined: Fri Jul 15, 2016 1:35 pm

Re: Check box based on data connector

Post by Stub » Wed Mar 11, 2020 2:35 pm

I'd try the values that are possible to be assigned to an attribute via Ranorex Spy. The Checked attribute allows True/False, while CheckState allows Unchecked, Checked and Indeterminate. Not sure why True/False wouldn't work via SetValue. I'm not familiar with Recordings I'm afraid, I go direct to the attribute via code.
Last edited by Stub on Wed Mar 11, 2020 2:40 pm, edited 1 time in total.

dmconsulting1
Posts: 91
Joined: Fri Nov 08, 2019 3:23 pm

Re: Check box based on data connector

Post by dmconsulting1 » Wed Mar 11, 2020 2:38 pm

OMG, it totally works. For some reason (it happens sometimes) Ranorex didn't see my datasheet changes, but I was able to finally get it to see the new column and it works. Thanks for the help on this, it really expands this test.

User avatar
Stub
Posts: 373
Joined: Fri Jul 15, 2016 1:35 pm

Re: Check box based on data connector

Post by Stub » Wed Mar 11, 2020 2:40 pm

Huzzah! It's wicked when a new trick like that works, and transforms the potential testing!

dmconsulting1
Posts: 91
Joined: Fri Nov 08, 2019 3:23 pm

Re: Check box based on data connector

Post by dmconsulting1 » Wed Mar 11, 2020 4:33 pm

Seriously, this is one test case that has never actually been done by hand end to end because of the number of variations and just how long it would take to do it. Adding the checkbox makes a total of 64 iterations.

I am importing an outside file format and converting it based on 1 of 8 supported versions.

Then I have options as to how I want the converted figures based on SAE or Metric measurements.

Then I have to validate that the file imported without error, and my converted measurements are correct.

Ranorex takes 20 seconds to import the file and validate that all 8 measurements are correct (4 alignment points X 2 pieces). While this isn't a test that will be ran more than maybe once a week, it is a feature that has bitten QA in the past because something was off in the conversion. It took me about 6 hours to build out this test and it runs to completion in around 20 minutes. This would take days to do by hand and would be a painful exercise.