我可以在量角器测试中访问文档或窗口对象吗? [英] Can I access the document or window objects from within a protractor test?
本文介绍了我可以在量角器测试中访问文档或窗口对象吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
也许这是不可能的,我真的不明白节点是如何工作的。我希望能够在量角器中获取页面后对文档对象运行断言。这样的事情是否可能,如果可能的话?
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?
谢谢!
推荐答案
好的,找到了答案,所以我正在回答其他人的问题:
Ok, found the answer, so am answering my own question for others:
你可以使用browser.executeScript执行javascript,然后在你的诺言中使用返回值分辨率,如下:
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 );
});
这篇关于我可以在量角器测试中访问文档或窗口对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文