Access and validate a html checkbox

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
boris0dev
Posts: 15
Joined: Fri Nov 09, 2018 11:28 am

Access and validate a html checkbox

Post by boris0dev » Mon Jul 22, 2019 3:08 pm

Hi Ranorex forum,
in a web application I have a (invisible) checkbox:
The attachment 2019-07-22 13_56_56-Technikertool.png is no longer available
In the repository I identify the element as WebElement and Ranorex Spy has no problem to find the element:
2019-07-22 13_56_56-Technikertool.png
2019-07-22 13_56_56-Technikertool.png (89.81 KiB) Viewed 116 times
My goal: I want to see if the checkbox is checked.

As it is a webelement I have to convert it to a Ranorex.Checkbox element or at least to an InputTag element - don't I?

There are various ways I tried to do it:

InputTag checkbox = (InputTag)[path to element in repository].CheckboxShowOnscreenKeyboard;
Checkbox checkbox = (Checkbox)[path to element in repository].CheckboxShowOnscreenKeyboard;

I've also set the type of the element in the repository to "Unknown" and tried in multiple ways to create an adapter out of it. Just one way (I don't list all the ideas I had):

CheckBox checkbox = (CheckBox)[path to element in repository].CheckboxShowOnscreenKeyboardInfo.CreateAdapter<Unknown>(false);

In the end I just want to successfully execute:

if (checkbox.Checked) {
Report.Info("checkbox is checked");
}

Any help _very_ appreciated
Thanks,
Boris

manish
Posts: 46
Joined: Fri Aug 10, 2018 12:46 pm

Re: Access and validate a html checkbox

Post by manish » Tue Jul 23, 2019 8:33 am

Hi,

Could you please upload a Ranorex Snapshot of the checkbox. Unfortunately, it is very difficult to tell about the issue without looking at the snapshot.

BR
Manish