Skip to content

Instantly share code, notes, and snippets.

@edgahan
Last active November 13, 2015 14:13
Show Gist options
  • Save edgahan/3d713bf4d3b684f93cec to your computer and use it in GitHub Desktop.
Save edgahan/3d713bf4d3b684f93cec to your computer and use it in GitHub Desktop.
scrolling protractor
# utils.js
module.exports = {
scrollIntoView: function(el) {
browser.executeScript(function(el) {
el.scrollIntoView();
}, el.getWebElement());
}
}
# inside page object somewhere...
var scrollIntoView = require('../utils').scrollIntoView;
module.exports = {
clickBackBtn: function() {
var el = element(by.buttonText('Go back'));
scrollIntoView(el);
el.click();
return;
}
}
# in the test itself...
it('should allow the user to go back to the profile page', function() {
PageObject.clickBackBtn();
expect(browser.getCurrentUrl()).toContain('/user/profile');
});
@damien-m
Copy link

👍 💯

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