cancel
Showing results for 
Search instead for 
Did you mean: 

How to check the state of the checkbox?

SOLVED
Amna
Occasional Contributor

How to check the state of the checkbox?

In my test script there is a screen from which I have to check that either the checkbox is being checked or unchecked . If the checkbox state is checked then it should display the message that state is enabled otherwise checkbox have to be select through test script

 

See attached image for reference

1 ACCEPTED SOLUTION

Accepted Solutions
BenoitB
Community Hero

Re: How to check the state of the checkbox?

Sorry but this is not clear for me.

 

You want to examine the value of a checkbox

And if the value is checked (true) then allow user to change the value.

 

That's what you need ?

 

To ask user to set a value you can use (quick and dirty code) :

let checkboxValue = myWebObject.checked;
if (checkboxValue) {
  let result = MessageDlg("Choose value of the checkbox by hitting the Yes for true or No for False", mtConfirmation, MkSet(mbYes, mbNo), 0);
  myWebObject.checked = result == mrYes;
}

 

 

 

Un sourire et ça repart

View solution in original post

4 REPLIES 4
AlexKaras
Community Hero

Re: How to check the state of the checkbox?

Hi,

 

Examine this web element in the Object Browser and figure-out what property indicates the state.

This is because web page developers can use different web elements and techniques to output something that is rendered as a check-box.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
sonya_m
Community Manager

Re: How to check the state of the checkbox?

Thanks Alex!

 

 

Hi @Amna ! Does this advice help?


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Amna
Occasional Contributor

Re: How to check the state of the checkbox?

Actually what I want that if the checkboxes already checked then we can display the message the its already checked you can modify your selection something like that

BenoitB
Community Hero

Re: How to check the state of the checkbox?

Sorry but this is not clear for me.

 

You want to examine the value of a checkbox

And if the value is checked (true) then allow user to change the value.

 

That's what you need ?

 

To ask user to set a value you can use (quick and dirty code) :

let checkboxValue = myWebObject.checked;
if (checkboxValue) {
  let result = MessageDlg("Choose value of the checkbox by hitting the Yes for true or No for False", mtConfirmation, MkSet(mbYes, mbNo), 0);
  myWebObject.checked = result == mrYes;
}

 

 

 

Un sourire et ça repart

View solution in original post

New Here?
Join us and watch the welcome video:
Top Kudoed Authors