Skip to content

Instantly share code, notes, and snippets.

@michaelwills
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelwills/f362e2368422f80ea831 to your computer and use it in GitHub Desktop.
Save michaelwills/f362e2368422f80ea831 to your computer and use it in GitHub Desktop.
Use intern.io to iterate and click elements sequentially
// uses when
// reduce and when suggested https://gist.github.com/michaelwills/f362e2368422f80ea831#comment-1454585
var when = require('intern/dojo/promise/when');
// snippet from previous this.remote sequence
this.remote
.findAllByCssSelector('.tile')
.then(function onTileImages(tiles) {
return tiles.reduce(function iterTiles(prev, tile) {
return when(prev)
.then(function iterTile() {
return tile.click()
.then(function () { return remote.pressKeys('\uE00C'); })
.then(function () { return remote.sleep(500); });
});
}, null);
})
.end();
@neonstalwart
Copy link

.findAllByCssSelector('.tile')
.then(function (tiles) {
  return tiles.reduce(function (prev, tile) {
    return when(prev)
    .then(function () {
        return tile.click()
        .then(function () { return remote.pressKeys('\uE00C'); })
        .then(function () { return remote.sleep(500); });
    });
  }, null);
});

@michaelwills
Copy link
Author

Thanks @neoonstalwart!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment