2017-04-18 63 views
1

我想运行一个测试套件无头(使用PhantomJS)编写的量角器,但是当我运行命令'phantomjs testSuiteFile.js'我得到错误:ReferenceError: Can't find variable: browser。浏览器变量在我所有的测试中都很重要,所以有没有办法让phantomjs找到使用浏览器对象的&?与PhantomJS使用量角器的'浏览器'对象

我也试过配置我的量角器配置文件使用phantomjs,我开始硒的webdriver使用在文档中推荐的命令phantomjs:phantomjs --webdriver=9134protractor protractor.conf.js跑的配置文件。配置文件被设置为只运行myTest.js,现在我得到错误E/launcher - Error: Error: Cannot find module 'webpage'

var WebPage = require('webpage'); 
page = WebPage.create(); 
page.open('http://google.com'); 
page.onLoadFinished = function() { 
    page.render('googleScreenShot' + '.png'); 
    phantom.exit();} 

回答

0

这不是如何ProtractorPhantomJS一起工作:但是当我运行phantomjs myTest.js

myTest.js myTest.js工作。您需要execute protractor command from the command-line以使browser和其他量角器全局变量初始化。

+0

感谢您的建议,我更新了我的问题以包含它 – John123

相关问题