i have written first acceptance test angular 2 using protractor + cucumber , seems when call table.filter browser hangs , times out till timeout time.
i using chai-as-promised expectations:
var chai = require('chai'); var chaiaspromised = require('chai-as-promised'); chai.use(chaiaspromised); var expect = chai.expect;
below code doesn't work.
var grid = $$(".table tr"); grid.filter(function (row) { var cells = row.$$('td'); expect(cells.get(0).gettext()).to.eventually.equal(factoryname).and.notify(done);
i have managed make scenario pass replacing above code with:
var grid = $$(".table tr"); (var = 1; < grid.count() ; i++) { var cells = grid.get(i).$$('td'); expect(cells.get(0).gettext()).to.eventually.equal(factoryname).and.notify(done); }
i struggling find reason why table.filter causing timeouts.
can me article/post, how convert these steps.js typescript proper way of testing in angular2?
.filter()
expects filter function have returned it (a boolean value, or promise resolving boolean value, decide whether skip element in array or not).
from understand, meant:
var grid = $$(".table tr"); var desiredrow = grid.filter(function (row) { var cells = row.$$('td'); return cells.first().gettext().then(function(celltext) { return celltext === factoryname; }); }).first(); // desiredrow
or, if meant check first cell of every row equal factoryname
, should/could have used each()
:
var grid = $$(".table tr"); grid.each(function (row) { var cells = row.$$('td'); expect(cells.first().gettext()).to.eventually.equal(factoryname); });
or, could've located first cell of every row using first-of-type
css selector pseudo-class , assert elements of array have factoryname
value:
var cells = $$(".table tr td:first-of-type"); // example 2 rows // n rows, http://stackoverflow.com/questions/14832603/check-if-all-values-of-array-are-equal expect(cells.gettext()).toequal([factoryname, factoryname]);
Comments
Post a Comment