Commit 8f35291d authored by Addy Osmani's avatar Addy Osmani

Merge pull request #791 from ColinEberhardt/browser-tests-squashed

Automated UI tests for TodoMVC using WebdriverJS (Selenium)
parents a42eb2b9 b1ec2604
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-simple-mocha');
var gruntConfig = {
simplemocha: {
options: {
reporter: 'mocha-known-issues-reporter'
},
files: {
src: 'allTests.js'
}
}
};
grunt.initConfig(gruntConfig);
// build tasks
grunt.registerTask('test', ['simplemocha']);
};
#Overview
The TodoMVC project has a great many implementations of exactly the same app using different MV* frameworks. Each app should be functionally identical. The goal of these tests is to provide a fully automated browser-based test that can be used to ensure that the specification is being followed by each and every TodoMVC app.
##Todo
+ Complete the test implementation (27 out of 28 are now complete). The only test that I am struggling with is to test that the delete button becomes visible on hover.
+ Find a more elegant solution for TodoMVC apps that use RequireJS, currently there is a short 'sleep' statement in order to give the browser time to load dependencies. Yuck!
+ Run JSHint over my code ;-)
+ Make it work with PhantomJS. In practice, Phantom is only a little bit faster, but it should work. Currently there are a few Phantom specific failures.
##Running the tests
These tests use Selenium 2 (WebDriver), via the JavaScript API (WebdriverJS). In order to run the tests you will need to install the dependencies. Run the following command from within the `browser-tests` folder:
npm install
The tests use mocha, which must be installed as a command line module:
sudo npm install -g mocha
You need to run a local server at the root of the TodoMVC project. On Mac OSX, you can do the following:
python -m SimpleHTTPServer 8000
To run the tests for all TodoMVC implementations, run the following:
mocha allTests.js --reporter spec
Note that `--reporter spec` uses the mocha 'spec' reporter, which is quite informative. You can of course specify any other reported.
In order to run tests for a single TodoMVC implementation, supply a framework argument as follows:
mocha allTests.js --reporter spec --framework=angularjs
In order to run a specific test, using the mocha 'grep' function. For example:
$ mocha allTests.js --reporter spec --framework=jquery \
--grep 'should trim entered text'
TodoMVC - jquery
Editing
✓ should trim entered text (1115ms)
1 passing (3s)
##Reporting against known issues
The `knownIssues.js` file details the currently known issues with the TodoMVC implementations. You can run the tests and compare against these issues using the `mocha-known-issues-reporter`. This reported is a separate npm module, as a result the easier way to run it using the supplied gruntfile:
grunt test --framework=angularjs
When run via grunt the suite supports exactly the same command line arguments.
An example output with the known issues reporter is shown below:
$ grunt test --framework=jquery
Running "simplemocha:files" (simplemocha) task
(1 of 27) pass: TodoMVC - jquery, No Todos, should hide #main and #footer
[...]
(17 of 27) pass: TodoMVC - jquery, Editing, should remove the item if an empty text string was entered
(18 of 27) known issue: TodoMVC - jquery, Editing, should cancel edits on escape -- error: undefined
(19 of 27) pass: TodoMVC - jquery, Counter, should display the current number of todo items
(20 of 27) pass: TodoMVC - jquery, Clear completed button, should display the number of completed items
(21 of 27) pass: TodoMVC - jquery, Clear completed button, should remove completed items when clicked
(22 of 27) pass: TodoMVC - jquery, Clear completed button, should be hidden when there are no items that are completed
(23 of 27) pass: TodoMVC - jquery, Persistence, should persist its data
(24 of 27) known issue: TodoMVC - jquery, Routing, should allow me to display active items -- error: Cannot call method 'click' of undefined
(25 of 27) known issue: TodoMVC - jquery, Routing, should allow me to display completed items -- error: Cannot call method 'click' of undefined
(26 of 27) known issue: TodoMVC - jquery, Routing, should allow me to display all items -- error: Cannot call method 'click' of undefined
(27 of 27) known issue: TodoMVC - jquery, Routing, should highlight the currently applied filter -- error: Cannot call method 'getAttribute' of undefined
passed: 22/27
failed: 5/27
new issues: 0
resolved issues: 0
The reporter indicates the number of passes, failed, new and resolved issues. This makes it ideal for regression testing.
###Chrome
In order to run the tests using the Chrome browser, you need to install ChromeDriver. Instructions for download and installation can be found on the [ChromeDriver homepage](http://code.google.com/p/selenium/wiki/ChromeDriver), or a simpler set of instructions is available [here](http://damien.co/resources/how-to-install-chromedriver-mac-os-x-selenium-python-7406).
###Example output
A test run with the 'spec' reporter look something like the following:
$ mocha allTests.js --reporter spec --framework=angularjs
angularjs
TodoMVC
No Todos
✓ should hide #main and #footer (201ms)
New Todo
✓ should allow me to add todo items (548ms)
✓ should clear text input field when an item is added (306ms)
✓ should trim text input (569ms)
✓ should show #main and #footer when items added (405ms)
Mark all as completed
✓ should allow me to mark all items as completed (1040ms)
✓ should allow me to clear the completion state of all items (1014ms)
✓ complete all checkbox should update state when items are completed (1413ms)
Item
✓ should allow me to mark items as complete (843ms)
✓ should allow me to un-mark items as complete (978ms)
✓ should allow me to edit an item (1155ms)
✓ should show the remove button on hover
Editing
✓ should hide other controls when editing (718ms)
✓ should save edits on enter (1093ms)
✓ should save edits on blur (1256ms)
✓ should trim entered text (1163ms)
✓ should remove the item if an empty text string was entered (1033ms)
✓ should cancel edits on escape (1115ms)
Counter
✓ should display the current number of todo items (462ms)
Clear completed button
✓ should display the number of completed items (873ms)
✓ should remove completed items when clicked (898ms)
✓ should be hidden when there are no items that are completed (893ms)
Persistence
✓ should persist its data (3832ms)
Routing
✓ should allow me to display active items (871ms)
✓ should allow me to display completed items (960ms)
✓ should allow me to display all items (1192ms)
✓ should highlight the currently applied filter (1095ms)
27 passing (1m)
##Speed mode
In order to keep each test case fully isolated, the browser is closed then re-opened in between each test. This does mean that the tests can take quite a long time to run. If you don't mind the risk of side-effects you can run the tests in speed mode by adding the `--speedMode` argument.
mocha allTests.js --reporter spec --speedMode
Before each test all the todo items are checked as completed and the 'clear complete' button pressed. This make the tests run in around half the time, but with the obvious risk that the tear-down code may fail.
##Lax mode
There are certain implementations (e.g. GWT and Dojo) where the constraints of the framework mean that it is not possible to match exactly the HTML specification for TodoMVC. In these cases the tests can be run in a 'lax' mode where the XPath queries used to locate DOM elements are more general. For example, rather than looking for a checkbox `input` element with a class of `toggle`, in lax mode it simply looks for any `input` elements of type `checkbox`. To run the tests in lax mode, simply use the `--laxMode` argument:
mocha allTests.js --reporter spec --laxMode
##Test design
Very briefly, the tests are designed as follows:
+ `page.js` - provides an abstraction layer for the HTML template. All the code required to access elements from the DOM is found within this file. The XPaths used to locate elements are based on the TodoMVC specification, using the required element classes / ids.
+ `pageLaxMode.js` - extends the above in order to relax the XPath constraints.
+ `testOperations.js` - provides common assertions and operations.
+ `test.js` - Erm … the tests! These are written to closely match the TodoMVC spec.
+ `allTest.js` - A simple file that locates all of the framework examples, and runs the tests for each.
**NOTE:** All of the WebdriverJS methods return promises and are executed asynchronously. However, you do not have to 'chain' then using `then`, they are instead automagically added to a queue, then executed. This means that if you add non-WebdriverJS operations (asserts, log messages) these will not be executed at the point you might expect. This is why `TestOperations.js` uses an explicit `then` each time it asserts.
\ No newline at end of file
var testSuite = require('./test.js'),
fs = require('fs'),
argv = require('optimist').default('laxMode', false).argv,
rootUrl = "http://localhost:8000/",
frameworkNamePattern = /^[a-z-_]+$/;
// collect together the framework names from each of the subfolders
var list = fs.readdirSync("../architecture-examples/")
.map(function(folderName) { return { name : folderName, path : "architecture-examples/" + folderName} });
list = list.concat(fs.readdirSync("../labs/architecture-examples/")
.map(function(folderName) { return { name : folderName, path: "labs/architecture-examples/" + folderName} }));
list = list.concat(fs.readdirSync("../labs/dependency-examples/")
.map(function(folderName) { return { name : folderName, path: "labs/dependency-examples/" + folderName} }));
list = list.concat(fs.readdirSync("../dependency-examples/")
.map(function(folderName) { return { name : folderName, path: "dependency-examples/" + folderName} }));
// apps that are not hosted at the root of their folder need to be handled explicitly
var exceptions = [
{ name : "chaplin-brunch", path : "labs/dependency-examples/chaplin-brunch/public" }
];
list = list.map(function(framework) {
var exception = exceptions.filter(function(exFramework) { return exFramework.name === framework.name});
return exception.length > 0 ? exception[0] : framework;
});
// filter out any folders that are not frameworks (.e.g hidden files)
list = list.filter(function(framework) { return frameworkNamePattern.test(framework.name); });
// if a specific framework has been named, just run this one
if (argv.framework) {
list = list.filter(function(framework) { return framework.name === argv.framework});
}
// run the tests for each framework
var testIndex = 1;
list.forEach(function(framework) {
testSuite.todoMVCTest(framework.name,
rootUrl + framework.path + "/index.html", argv.speedMode, argv.laxMode);
});
module.exports = [
// the following are covered by the following issue:
// https://github.com/tastejs/todomvc/issues/789
"TodoMVC - agilityjs, Editing, should cancel edits on escape",
"TodoMVC - angularjs-perf, Editing, should cancel edits on escape",
"TodoMVC - closure, Editing, should cancel edits on escape",
"TodoMVC - jquery, Editing, should cancel edits on escape",
"TodoMVC - knockback, Editing, should cancel edits on escape",
"TodoMVC - spine, Editing, should cancel edits on escape",
"TodoMVC - yui, Editing, should cancel edits on escape",
// all the following are covered by this issue:
// https://github.com/tastejs/todomvc/issues/790
// these implementations filter the view rather than the model when routing
"TodoMVC - agilityjs, Routing, should allow me to display active items",
"TodoMVC - agilityjs, Routing, should allow me to display completed items",
"TodoMVC - backbone, Routing, should allow me to display active items",
"TodoMVC - backbone, Routing, should allow me to display completed items",
"TodoMVC - maria, Routing, should allow me to display active items",
"TodoMVC - maria, Routing, should allow me to display completed items",
"TodoMVC - dojo, Routing, should allow me to display active items",
"TodoMVC - dojo, Routing, should allow me to display completed items",
// the following are covered by this issue:
// https://github.com/tastejs/todomvc/issues/795
"TodoMVC - spine, Mark all as completed, complete all checkbox should update state when items are completed / cleared",
"TodoMVC - angularjs-perf, Mark all as completed, complete all checkbox should update state when items are completed / cleared",
// the following implementations do not support routing
"TodoMVC - jquery, Routing, should allow me to display active items",
"TodoMVC - jquery, Routing, should allow me to display completed items",
"TodoMVC - jquery, Routing, should allow me to display all items",
"TodoMVC - jquery, Routing, should highlight the currently applied filter",
// ----------------- Test framework issues -----------
// for some reason the persistence test fails for knockout, even though persistence is working
// just fine. Perhaps there is something asynchronous going on that is causing the assert
// to be executed early?
"TodoMVC - knockoutjs, Persistence, should persist its data",
// ----------------- Unsupported implementations!! -----------
// the following are TodoMVC implementations that are not supported by the autoated UI
// tests, and as a result have numerous failures.
// polymer - does not follow the HTML spec
"TodoMVC - polymer, New Todo, should allow me to add todo items",
"TodoMVC - polymer, New Todo, should clear text input field when an item is added",
"TodoMVC - polymer, New Todo, should trim text input",
"TodoMVC - polymer, New Todo, should show #main and #footer when items added",
"TodoMVC - polymer, Mark all as completed, should allow me to mark all items as completed",
"TodoMVC - polymer, Mark all as completed, should allow me to clear the completion state of all items",
"TodoMVC - polymer, Mark all as completed, complete all checkbox should update state when items are completed / cleared",
"TodoMVC - polymer, Item, should allow me to mark items as complete",
"TodoMVC - polymer, Item, should allow me to un-mark items as complete",
"TodoMVC - polymer, Item, should allow me to edit an item",
"TodoMVC - polymer, Editing, should hide other controls when editing",
"TodoMVC - polymer, Editing, should save edits on enter",
"TodoMVC - polymer, Editing, should save edits on blur",
"TodoMVC - polymer, Editing, should trim entered text",
"TodoMVC - polymer, Editing, should remove the item if an empty text string was entered",
"TodoMVC - polymer, Editing, should cancel edits on escape",
"TodoMVC - polymer, Counter, should display the current number of todo items",
"TodoMVC - polymer, Clear completed button, should display the number of completed items",
"TodoMVC - polymer, Clear completed button, should remove completed items when clicked",
"TodoMVC - polymer, Clear completed button, should be hidden when there are no items that are completed",
"TodoMVC - polymer, Persistence, should persist its data",
"TodoMVC - polymer, Routing, should allow me to display active items",
"TodoMVC - polymer, Routing, should allow me to display completed items",
"TodoMVC - polymer, Routing, should allow me to display all items",
"TodoMVC - polymer, Routing, should highlight the currently applied filter",
// gwt - does not follow the HTML spec closely eough for testing
"TodoMVC - gwt, New Todo, should allow me to add todo items",
"TodoMVC - gwt, New Todo, should trim text input",
"TodoMVC - gwt, Mark all as completed, should allow me to mark all items as completed",
"TodoMVC - gwt, Mark all as completed, should allow me to clear the completion state of all items",
"TodoMVC - gwt, Mark all as completed, complete all checkbox should update state when items are completed / cleared",
"TodoMVC - gwt, Item, should allow me to mark items as complete",
"TodoMVC - gwt, Item, should allow me to un-mark items as complete",
"TodoMVC - gwt, Item, should allow me to edit an item",
"TodoMVC - gwt, Editing, should hide other controls when editing",
"TodoMVC - gwt, Editing, should save edits on enter",
"TodoMVC - gwt, Editing, should save edits on blur",
"TodoMVC - gwt, Editing, should trim entered text",
"TodoMVC - gwt, Editing, should remove the item if an empty text string was entered",
"TodoMVC - gwt, Editing, should cancel edits on escape",
"TodoMVC - gwt, Clear completed button, should display the number of completed items",
"TodoMVC - gwt, Clear completed button, should remove completed items when clicked",
"TodoMVC - gwt, Clear completed button, should be hidden when there are no items that are completed",
"TodoMVC - gwt, Persistence, should persist its data",
"TodoMVC - gwt, Routing, should allow me to display active items",
"TodoMVC - gwt, Routing, should allow me to display completed items",
"TodoMVC - gwt, Routing, should allow me to display all items",
"TodoMVC - gwt, Routing, should highlight the currently applied filter",
];
\ No newline at end of file
{
"name": "TodoMVC-Browser-Tests",
"description": "An automated test suite for TodoMVC",
"private": true,
"devDependencies": {
"grunt": "0.4.1",
"mocha": "1.14.0",
"selenium-webdriver": "2.37.0",
"optimist" : "0.6.0",
"grunt-simple-mocha": "~0.4.0",
"mocha-known-issues-reporter" : "git://github.com/ColinEberhardt/mocha-known-issues-reporter.git#v0.0.0"
}
}
var webdriver = require('selenium-webdriver');
function Page(browser, laxMode) {
// ----------------- utility methods
this.xPathForItemAtIndex = function(index) {
// why is XPath the only language silly enough to be 1-indexed?
return "//ul[@id='todo-list']/li[" + (index + 1) + "]";
}
// ----------------- try / get methods
// unfortunately webdriver does not have a decent API for determining if an
// element exists. The standard approach is to obtain an array of elements
// and test that the length is zero. These methods are used to obtain
// elements which *might* be present in the DOM, hence the try/get name.
this.tryGetMainSectionElement = function() {
return browser.findElements(webdriver.By.xpath("//section[@id='main']"));
}
this.tryGetFooterElement = function() {
return browser.findElements(webdriver.By.xpath("//footer[@id='footer']"));
}
this.tryGetClearCompleteButton = function() {
return browser.findElements(webdriver.By.xpath("//button[@id='clear-completed']"));
}
this.tryGetToggleForItemAtIndex = function(index) {
var xpath = this.xPathForItemAtIndex(index) + "//input[contains(@class,'toggle')]";
return browser.findElements(webdriver.By.xpath(xpath));
}
this.tryGetItemLabelAtIndex = function(index) {
return browser.findElements(webdriver.By.xpath(this.xPathForItemAtIndex(index) + "//label"));
}
// ----------------- DOM element access methods
this.getEditInputForItemAtIndex = function(index) {
var xpath = this.xPathForItemAtIndex(index) + "//input[contains(@class,'edit')]";
return browser.findElement(webdriver.By.xpath(xpath));
}
this.getItemInputField = function() {
return browser.findElement(webdriver.By.xpath("//input[@id='new-todo']"));
}
this.getMarkAllCompletedCheckBox = function() {
return browser.findElement(webdriver.By.xpath("//input[@id='toggle-all']"));
}
this.getItemElements = function() {
return browser.findElements(webdriver.By.xpath("//ul[@id='todo-list']/li"));
}
this.getNonCompletedItemElements = function() {
return browser.findElements(webdriver.By.xpath("//ul[@id='todo-list']/li[not(contains(@class,'completed'))]"));
}
this.getItemsCountElement = function() {
return browser.findElement(webdriver.By.id("todo-count"));
}
this.getItemLabelAtIndex = function(index) {
return browser.findElement(webdriver.By.xpath(this.xPathForItemAtIndex(index) + "//label"));
}
this.getFilterElements = function() {
return browser.findElements(webdriver.By.xpath("//ul[@id='filters']//a"));
}
// ----------------- page actions
this.clickMarkAllCompletedCheckBox = function() {
return this.getMarkAllCompletedCheckBox().then(function(checkbox){
checkbox.click();
});
}
this.clickClearCompleteButton = function() {
return this.tryGetClearCompleteButton().then(function(elements) {
var button = elements[0];
button.click();
});
}
this.enterItem = function(itemText) {
var textField = this.getItemInputField();
textField.sendKeys(itemText);
textField.sendKeys(webdriver.Key.ENTER);
};
this.toggleItemAtIndex = function(index) {
return this.tryGetToggleForItemAtIndex(index).then(function(elements) {
var toggleElement = elements[0];
toggleElement.click();
});
}
this.editItemAtIndex = function(index, itemText) {
return this.getEditInputForItemAtIndex(index)
.then(function(itemEditField) {
// send 50 delete keypresses, just to be sure the item text is deleted
var deleteKeyPresses = "";
for (var i=0;i<50;i++) {
deleteKeyPresses += webdriver.Key.BACK_SPACE
}
itemEditField.sendKeys(deleteKeyPresses);
// update the item with the new text.
itemEditField.sendKeys(itemText);
});
};
this.doubleClickItemAtIndex = function(index) {
return this.getItemLabelAtIndex(index).then(function(itemLabel) {
// double click is not 'natively' supported, so we need to send the event direct to the element
// see: http://stackoverflow.com/questions/3982442/selenium-2-webdriver-how-to-double-click-a-table-row-which-opens-a-new-window
browser.executeScript("var evt = document.createEvent('MouseEvents');" +
"evt.initMouseEvent('dblclick',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);" +
"arguments[0].dispatchEvent(evt);", itemLabel);
});
}
this.filterByActiveItems = function(index) {
return this.getFilterElements().then(function(filters) {
filters[1].click();
});
}
this.filterByCompletedItems = function(index) {
return this.getFilterElements().then(function(filters) {
filters[2].click();
});
}
this.filterByAllItems = function(index) {
return this.getFilterElements().then(function(filters) {
filters[0].click();
});
}
}
module.exports = Page;
\ No newline at end of file
var webdriver = require('selenium-webdriver'),
Page = require("./page");
function PageLaxMode(browser) {
Page.apply(this, [browser]);
this.tryGetToggleForItemAtIndex = function(index) {
// the specification dictates that the checkbox should have the 'toggle' CSS class. Some implementations deviate from
// this, hence in lax mode we simply look for any checkboxes within the specified 'li'.
var xpath = this.xPathForItemAtIndex(index) + "//input[@type='checkbox']";
return browser.findElements(webdriver.By.xpath(xpath));
}
this.getEditInputForItemAtIndex = function(index) {
// the specification dictates that the input element that allows the user to edit a todo item should have a CSS
// class of 'edit'. In lax mode, we also look for an input of type 'text'.
var xpath = "(" + this.xPathForItemAtIndex(index) + "//input[@type='text']" + "|" +
this.xPathForItemAtIndex(index) + "//input[contains(@class,'edit')]" + ")";
return browser.findElement(webdriver.By.xpath(xpath));
}
}
module.exports = PageLaxMode;
\ No newline at end of file
This diff is collapsed.
var assert = require("assert");
function TestOperations(page) {
// unfortunately webdriver does not have a decent API for determining if an
// element exists. The standard approach is to obtain an array of elements
// and test that the length is zero. In this case the item is hidden if
// it is either not in the DOM, or is in the DOM but not visible.
function testIsHidden(elements) {
if (elements.length === 1) {
elements[0].isDisplayed().then(function(isDisplayed) {
assert(!isDisplayed);
})
}
}
function testIsVisible(elements) {
assert.equal(1, elements.length);
elements[0].isDisplayed().then(function(isDisplayed) {
assert(isDisplayed);
});
}
this.assertClearCompleteButtonIsHidden = function() {
page.tryGetClearCompleteButton().then(function(element) {
testIsHidden(element);
});
}
this.assertClearCompleteButtonIsVisible = function() {
page.tryGetClearCompleteButton().then(function(element) {
testIsVisible(element);
});
}
this.assertItemCount = function(itemCount) {
page.getItemElements().then(function(toDoItems){
assert.equal(itemCount, toDoItems.length);
});
}
this.assertClearCompleteButtonText = function(buttonText) {
page.tryGetClearCompleteButton().then(function(elements) {
var button = elements[0];
button.getText().then(function(text) {
assert.equal(buttonText, text);
});
});
}
this.assertMainSectionIsHidden = function() {
page.tryGetMainSectionElement().then(function(mainSection) {
testIsHidden(mainSection);
});
}
this.assertFooterIsHidden = function() {
page.tryGetFooterElement().then(function(footer) {
testIsHidden(footer);
});
}
this.assertMainSectionIsVisible = function() {
page.tryGetMainSectionElement().then(function(mainSection) {
testIsVisible(mainSection);
});
}
this.assertItemToggleIsHidden = function() {
page.tryGetToggleForItemAtIndex().then(function(toggleItem) {
testIsHidden(toggleItem);
});
}
this.assertItemLabelIsHidden = function() {
page.tryGetItemLabelAtIndex().then(function(toggleItem) {
testIsHidden(toggleItem);
});
}
this.assertFooterIsVisible = function() {
page.tryGetFooterElement().then(function(footer) {
testIsVisible(footer);
});
}
this.assertItemInputFieldText = function(text) {
page.getItemInputField().getText().then(function(inputFieldText) {
assert.equal(text, inputFieldText);
});
}
this.assertItemText = function(itemIndex, textToAssert) {
page.getItemLabelAtIndex(itemIndex).getText().then(function(text) {
assert.equal(textToAssert, text.trim());
});
}
this.assertItemCountText = function(textToAssert) {
page.getItemsCountElement().getText().then(function(text) {
assert.equal(textToAssert, text.trim());
});
}
// tests for the presence of the 'completed' CSS class for the item at the given index
this.assertItemAtIndexIsCompleted = function(index) {
page.getItemElements().then(function(toDoItems) {
toDoItems[index].getAttribute("class").then(function(cssClass) {
assert(cssClass.indexOf("completed") !== -1);
});
});
}
this.assertItemAtIndexIsNotCompleted = function(index) {
page.getItemElements().then(function(toDoItems) {
toDoItems[index].getAttribute("class").then(function(cssClass) {
// the maria implementation uses an 'incompleted' CSS class which is redundant
// TODO: this should really be moved into the pageLaxMode
assert(cssClass.indexOf("completed") === -1 || cssClass.indexOf("incompleted") !== -1);
});
});
}
function isSelected(cssClass) {
return cssClass.indexOf("selected") !== -1;
}
this.assertFilterAtIndexIsSelected = function(index) {
page.getFilterElements().then(function(filterElements) {
filterElements[0].getAttribute("class").then(function(cssClass) {
assert(index == 0 ? isSelected(cssClass) : !isSelected(cssClass));
});
filterElements[1].getAttribute("class").then(function(cssClass) {
assert(index == 1 ? isSelected(cssClass) : !isSelected(cssClass));
});
filterElements[2].getAttribute("class").then(function(cssClass) {
assert(index == 2 ? isSelected(cssClass) : !isSelected(cssClass));
});
});
}
this.assertCompleteAllIsClear = function() {
page.getMarkAllCompletedCheckBox().then(function(markAllCompleted) {
markAllCompleted.isSelected().then(function(isSelected){
assert(!isSelected);
})
});
}
this.assertCompleteAllIsChecked = function() {
page.getMarkAllCompletedCheckBox().then(function(markAllCompleted) {
markAllCompleted.isSelected().then(function(isSelected){
assert(isSelected);
})
});
}
}
module.exports = TestOperations;
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment