Skip to content

Commit 81dd50b

Browse files
committed
assert and verify checked and not checked
1 parent ad83b75 commit 81dd50b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

packages/selenium-ide/src/neo/models/Command.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export const Commands = Object.freeze({
7070
addSelection: "add selection",
7171
answerOnNextPrompt: "answer on next prompt",
7272
assertAlert: "assert alert",
73+
assertChecked: "assert checked",
74+
assertNotChecked: "assert not checked",
7375
assertConfirmation: "assert confirmation",
7476
assertEditable: "assert editable",
7577
assertNotEditable: "assert not editable",
@@ -104,6 +106,8 @@ export const Commands = Object.freeze({
104106
storeText: "store text",
105107
storeTitle: "store title",
106108
type: "type",
109+
verifyChecked: "verify checked",
110+
verifyNotChecked: "verify not checked",
107111
verifyEditable: "verify editable",
108112
verifyNotEditable: "verify not editable",
109113
verifyElementPresent: "verify element present",

packages/selenium-ide/src/selenium-api.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,24 @@ Selenium.prototype.reset = function() {
347347
this.browserbot.resetPopups();
348348
};
349349

350+
Selenium.prototype.doVerifyChecked = function(locator) {
351+
let element = this.browserbot.findElement(locator);
352+
if (element.type !== "checkbox" && element.type !== "radio") {
353+
throw new Error(`Element with locator ${locator} is not a checkbox nor a radio button`);
354+
} else if (!element.checked) {
355+
throw new Error(`Element with locator ${locator} is not checked`);
356+
}
357+
};
358+
359+
Selenium.prototype.doVerifyNotChecked = function(locator) {
360+
let element = this.browserbot.findElement(locator);
361+
if (element.type !== "checkbox" && element.type !== "radio") {
362+
throw new Error(`Element with locator ${locator} is not a checkbox nor a radio button`);
363+
} else if (element.checked) {
364+
throw new Error(`Element with locator ${locator} is checked`);
365+
}
366+
};
367+
350368
Selenium.prototype.doVerifyEditable = function(locator) {
351369
if (!this.isEditable(locator)) {
352370
throw new Error(`Element with locator ${locator} is not editable`);
@@ -402,6 +420,24 @@ Selenium.prototype.doVerifyElementNotPresent = function(locator) {
402420
}
403421
};
404422

423+
Selenium.prototype.doAssertChecked = function(locator) {
424+
let element = this.browserbot.findElement(locator);
425+
if (element.type !== "checkbox" && element.type !== "radio") {
426+
throw new Error(`Element with locator ${locator} is not a checkbox nor a radio button`);
427+
} else if (!element.checked) {
428+
throw new Error(`Element with locator ${locator} is not checked`);
429+
}
430+
};
431+
432+
Selenium.prototype.doAssertNotChecked = function(locator) {
433+
let element = this.browserbot.findElement(locator);
434+
if (element.type !== "checkbox" && element.type !== "radio") {
435+
throw new Error(`Element with locator ${locator} is not a checkbox nor a radio button`);
436+
} else if (element.checked) {
437+
throw new Error(`Element with locator ${locator} is checked`);
438+
}
439+
};
440+
405441
Selenium.prototype.doAssertEditable = function(locator) {
406442
if (!this.isEditable(locator)) {
407443
throw new Error(`Element with locator ${locator} is not editable`);

0 commit comments

Comments
 (0)