Maybe this isn't possible, I don't really understand how node works yet. I'd like to be able to run an assertion on the document object after a page has been fetched in protractor. Is such a thing possible, and if so how?
thanks!
Maybe this isn't possible, I don't really understand how node works yet. I'd like to be able to run an assertion on the document object after a page has been fetched in protractor. Is such a thing possible, and if so how?
thanks!
Share Improve this question asked Oct 31, 2014 at 1:11 Iain DuncanIain Duncan 1,77217 silver badges19 bronze badges2 Answers
Reset to default 15Ok, found the answer, so am answering my own question for others:
You can execute javascript using browser.executeScript and then use the return value in your promise resolution, like so:
browser.executeScript('return document._config').then( function(_config){
expect( _config.epid ).toBe( 1 );
});
The feature you are looking for is called executeScript or executeAsyncScript. They will help you execute an arbitrary piece of javascript in the browser.
Take a look at these links: http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.executeScript http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.executeAsyncScript