Skip to content

Commit 996ba8f

Browse files
committed
assert and verify selected value and not selected value
1 parent 81dd50b commit 996ba8f

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ export const Commands = Object.freeze({
7878
assertElementPresent: "assert element present",
7979
assertElementNotPresent: "assert element not present",
8080
assertPrompt: "assert prompt",
81+
assertSelectedValue: "assert selected value",
82+
assertNotSelectedValue: "assert not selected value",
8183
assertText: "assert text",
82-
assertValue: "assert value",
8384
assertTitle: "assert title",
85+
assertValue: "assert value",
8486
chooseCancelOnNextConfirmation: "choose cancel on next confirmation",
8587
chooseCancelOnNextPrompt: "choose cancel on next prompt",
8688
chooseOkOnNextConfirmation: "choose ok on next confirmation",
@@ -112,9 +114,11 @@ export const Commands = Object.freeze({
112114
verifyNotEditable: "verify not editable",
113115
verifyElementPresent: "verify element present",
114116
verifyElementNotPresent: "verify element not present",
117+
verifySelectedValue: "verify selected value",
118+
verifyNotSelectedValue: "verify not selected value",
115119
verifyText: "verify text",
116-
verifyValue: "verify value",
117-
verifyTitle: "verify title"
120+
verifyTitle: "verify title",
121+
verifyValue: "verify value"
118122
});
119123

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

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,25 @@ Selenium.prototype.doVerifyNotEditable = function(locator) {
377377
}
378378
};
379379

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+
380399
Selenium.prototype.doVerifyText = function(locator, value) {
381400
let element = this.browserbot.findElement(locator);
382401
if (getText(element) !== value) {
@@ -450,6 +469,24 @@ Selenium.prototype.doAssertNotEditable = function(locator) {
450469
}
451470
};
452471

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+
453490
Selenium.prototype.doAssertText = function(locator, value) {
454491
let element = this.browserbot.findElement(locator);
455492
if (getText(element) !== value) {

0 commit comments

Comments
 (0)