How to check if a check box is checked.
I have a test which checks "check boxes" using the Subject7 check function. This works well, so my locators are correct.
I would like to read back the value of the check box (whether checked or not) later in the test. Get_web_value always returns "on" whether the box is checked or not. Any ideas on how I can read back the checkbox value?
Sure. That I can do. It appears to look the same no matter what. But Subject7 seems to be able to read it to check it or uncheck it.
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
--indigo: #6610f2;
--pink: #e83e8c;
--yellow: #ffb819;
--cyan: #17a2b8;
--gray-dark: #343a40;
--black: #000;
--gray: #616265;
--lightgray: #b2b3b2;
--gray91: #e8e8e8;
--white: #fff;
--navyblue: #14284b;
--navybluelight: #e7e9ed;
--navybluedark: #d0d4db;
--purple: #6c3a77;
--purplelight: #f0ebf1;
--purpledark: #e2d8e4;
--blue: #20558a;
--bluelight: #e8eef3;
--bluedark: #d2dde8;
--teal: #005f71;
--teallight: #e5eff1;
--tealdark: #ccdfe3;
--red: #c0143c;
--redlight: #f9e7eb;
--reddark: #f2d0d8;
--green: #719500;
--greenlight: #f1f4e5;
--greendark: #e1e8cc;
--orange: #e57200;
--orangelight: #fcf1e5;
--orangedark: #fae3cc;
--lightblue: #5f9baf;
--lightbluelight: #eff5f7;
--lightbluedark: #dfebef;
--warmyellow: #ffb819;
--warmyellowlight: #fff8e8;
--warmyellowdark: #fff1d1;
--primary: #20558a;
--secondary: #6c757d;
--success: #719500;
--info: #17a2b8;
--warning: #ffb819;
--danger: #c0143c;
--light: #f8f9fa;
--dark: #343a40;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
--font-family-sans-serif: "Helvetica Neue",helvetica,arial,sans-serif;
--font-family-monospace: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
pointer-events: auto;
border-collapse: separate !important;
border-spacing: 0;
word-wrap: break-word;
word-break: break-word;
Before the checkbox is checked:
<input id="select0" type="checkbox" title="Select">
After the checkbox is checked:
<input id="select0" type="checkbox" title="Select">
Krisztian, what I did is add the string (not including quotes) ":checked
" to the "Css Selector" box in the Subject7 locator. The xpath still needs to be in place.
I haven't verified it, but to check if it is not checked you could probably add this ":not(:checked)
"
This does mean you need to build additional locators for each verification in addition to the locator for checking/unchecking the check box.
Please sign in to leave a comment.