最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I access the document or window objects from within a protractor test? - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a comment  | 

2 Answers 2

Reset to default 15

Ok, 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

发布评论

评论列表(0)

  1. 暂无评论