Skip to content

Instantly share code, notes, and snippets.

@anilreddy
Last active October 21, 2016 09:54
Show Gist options
  • Save anilreddy/b7d482b6106cd816e3e2761acd7c257f to your computer and use it in GitHub Desktop.
Save anilreddy/b7d482b6106cd816e3e2761acd7c257f to your computer and use it in GitHub Desktop.
How to use Javascript executor in protractor instead of sendkeys
// Text to be entered
var text = 'My text value';
// Locator
var input = element(by.model('angularProperty'));
// Now you can use like this
setValue(text, input);
// Using this function
this.setValue = function (inputText, locator) {
browser.executeScript("arguments[0].setAttribute('value', '" + inputText +"')", locator);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment