Skip to content

Commit e55de24

Browse files
committed
Merge branch 'assertions'
2 parents 293e8c9 + 996ba8f commit e55de24

File tree

2 files changed

+126
-1
lines changed

2 files changed

+126
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,19 @@ 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",
76+
assertEditable: "assert editable",
77+
assertNotEditable: "assert not editable",
7478
assertElementPresent: "assert element present",
7579
assertElementNotPresent: "assert element not present",
7680
assertPrompt: "assert prompt",
81+
assertSelectedValue: "assert selected value",
82+
assertNotSelectedValue: "assert not selected value",
7783
assertText: "assert text",
7884
assertTitle: "assert title",
85+
assertValue: "assert value",
7986
chooseCancelOnNextConfirmation: "choose cancel on next confirmation",
8087
chooseCancelOnNextPrompt: "choose cancel on next prompt",
8188
chooseOkOnNextConfirmation: "choose ok on next confirmation",
@@ -101,10 +108,17 @@ export const Commands = Object.freeze({
101108
storeText: "store text",
102109
storeTitle: "store title",
103110
type: "type",
111+
verifyChecked: "verify checked",
112+
verifyNotChecked: "verify not checked",
113+
verifyEditable: "verify editable",
114+
verifyNotEditable: "verify not editable",
104115
verifyElementPresent: "verify element present",
105116
verifyElementNotPresent: "verify element not present",
117+
verifySelectedValue: "verify selected value",
118+
verifyNotSelectedValue: "verify not selected value",
106119
verifyText: "verify text",
107-
verifyTitle: "verify title"
120+
verifyTitle: "verify title",
121+
verifyValue: "verify value"
108122
});
109123

110124
export const CommandsArray = Object.freeze(Object.keys(Commands));

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

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,69 @@ 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+
368+
Selenium.prototype.doVerifyEditable = function(locator) {
369+
if (!this.isEditable(locator)) {
370+
throw new Error(`Element with locator ${locator} is not editable`);
371+
}
372+
};
373+
374+
Selenium.prototype.doVerifyNotEditable = function(locator) {
375+
if (this.isEditable(locator)) {
376+
throw new Error(`Element with locator ${locator} is editable`);
377+
}
378+
};
379+
380+
381+
Selenium.prototype.doVerifySelectedValue = function(locator, value) {
382+
let element = this.browserbot.findElement(locator);
383+
if (element.type !== "select-one") {
384+
throw new Error(`Element with locator ${locator} is not a select`);
385+
} else if (element.value !== value) {
386+
throw new Error("Actual value '" + element.value + "' did not match '" + value + "'");
387+
}
388+
};
389+
390+
Selenium.prototype.doVerifyNotSelectedValue = function(locator, value) {
391+
let element = this.browserbot.findElement(locator);
392+
if (element.type !== "select-one") {
393+
throw new Error(`Element with locator ${locator} is not a select`);
394+
} else if (element.value === value) {
395+
throw new Error("Actual value '" + element.value + "' did match");
396+
}
397+
};
398+
350399
Selenium.prototype.doVerifyText = function(locator, value) {
351400
let element = this.browserbot.findElement(locator);
352401
if (getText(element) !== value) {
353402
throw new Error("Actual value '" + getText(element) + "' did not match '" + value + "'");
354403
}
355404
};
356405

406+
Selenium.prototype.doVerifyValue = function(locator, value) {
407+
let element = this.browserbot.findElement(locator);
408+
if (element.value !== value) {
409+
throw new Error("Actual value '" + element.value + "' did not match '" + value + "'");
410+
}
411+
};
412+
357413
Selenium.prototype.doVerifyTitle = function(value) {
358414
if (normalizeSpaces(this.getTitle()) !== value) {
359415
throw new Error("Actual value '" + normalizeSpaces(this.getTitle()) + "' did not match '" + value + "'");
@@ -383,13 +439,68 @@ Selenium.prototype.doVerifyElementNotPresent = function(locator) {
383439
}
384440
};
385441

442+
Selenium.prototype.doAssertChecked = function(locator) {
443+
let element = this.browserbot.findElement(locator);
444+
if (element.type !== "checkbox" && element.type !== "radio") {
445+
throw new Error(`Element with locator ${locator} is not a checkbox nor a radio button`);
446+
} else if (!element.checked) {
447+
throw new Error(`Element with locator ${locator} is not checked`);
448+
}
449+
};
450+
451+
Selenium.prototype.doAssertNotChecked = function(locator) {
452+
let element = this.browserbot.findElement(locator);
453+
if (element.type !== "checkbox" && element.type !== "radio") {
454+
throw new Error(`Element with locator ${locator} is not a checkbox nor a radio button`);
455+
} else if (element.checked) {
456+
throw new Error(`Element with locator ${locator} is checked`);
457+
}
458+
};
459+
460+
Selenium.prototype.doAssertEditable = function(locator) {
461+
if (!this.isEditable(locator)) {
462+
throw new Error(`Element with locator ${locator} is not editable`);
463+
}
464+
};
465+
466+
Selenium.prototype.doAssertNotEditable = function(locator) {
467+
if (this.isEditable(locator)) {
468+
throw new Error(`Element with locator ${locator} is editable`);
469+
}
470+
};
471+
472+
Selenium.prototype.doAssertSelectedValue = function(locator, value) {
473+
let element = this.browserbot.findElement(locator);
474+
if (element.type !== "select-one") {
475+
throw new Error(`Element with locator ${locator} is not a select`);
476+
} else if (element.value !== value) {
477+
throw new Error("Actual value '" + element.value + "' did not match '" + value + "'");
478+
}
479+
};
480+
481+
Selenium.prototype.doAssertNotSelectedValue = function(locator, value) {
482+
let element = this.browserbot.findElement(locator);
483+
if (element.type !== "select-one") {
484+
throw new Error(`Element with locator ${locator} is not a select`);
485+
} else if (element.value === value) {
486+
throw new Error("Actual value '" + element.value + "' did match");
487+
}
488+
};
489+
386490
Selenium.prototype.doAssertText = function(locator, value) {
387491
let element = this.browserbot.findElement(locator);
388492
if (getText(element) !== value) {
389493
throw new Error("Actual value '" + getText(element) + "' did not match '" + value + "'");
390494
}
391495
};
392496

497+
Selenium.prototype.doAssertValue = function(locator, value) {
498+
let element = this.browserbot.findElement(locator);
499+
if (element.value !== value) {
500+
throw new Error("Actual value '" + element.value + "' did not match '" + value + "'");
501+
}
502+
};
503+
393504
Selenium.prototype.doAssertTitle = function(value) {
394505
if (normalizeSpaces(this.getTitle()) !== value) {
395506
throw new Error("Actual value '" + normalizeSpaces(this.getTitle()) + "' did not match '" + value + "'");

0 commit comments

Comments
 (0)