Tag: phantomjs

FuncUnit无法使用PhantomJS运行testing

我一直在尝试创build一系列functionunit testing,使用PhantomJS作为浏览器在Node.js Web服务器上运行,在另一个站点上testingfunction。 过去,我已经使用FuncUnit成功地从目标站点本身运行functiontesting,但为了testing规模,我创build了一个Node项目来执行此操作,在Heroku实例上运行。 我用Bower安装了JQuery,Jasmine(我正在使用的testing运行器)和FuncUnit。 我已经被告知,FuncUnit不支持最新版本的Jasmine,所以它在版本1.3.1 – 所有其他软件包在他们的最新版本。 Phantom已经安装了NPM,并打开了以下页面: <html> <head> <title>Functional Testing</title> <script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script> <script type="text/javascript" src="bower_components/syn/dist/syn.js"></script> <script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/jasmine.js"></script> <script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/jasmine-html.js"></script> <script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/json2.js"></script> <script type="text/javascript" src="bower_components/funcunit/dist/funcunit.js"></script> <script type="text/javascript" src="testSpec.js"></script> <script type="text/javascript"> // Standard Jasmine 1.3 boot script from examples </script> </head> <body> </body> </html> 一旦testing运行开始,我几乎立即遇到错误。 下面的部分似乎会导致崩溃,虽然我很难找出哪一行正如堆栈跟踪已certificate难以导航。 F.attach(jasmine); F.speed = 100; […]

如何确保在节点上使用mocha和phantomjs进行每个testing的未触及的HTML

我写了一个web应用程序,我想要使用摩卡和phantomjs从命令行做一些DOMtesting,我想找出最好的方法来做到这一点。 由于networking应用程序正在进行大量的DOM操作,我希望能够在每次testing中加载全新的DOM。 我试图使用phantomjs的网页模块,但我不知道如何在页面上运行摩卡testing(或者如果这是正确的方式)。 当然,我可以创build一个文件test.html ,其中包含通过脚本标签的mocha,然后运行phantomjs test.html 。 但是我怎样才能确保在每个testing中都没有触动DOM? 为每个具有相同内容的testing添加一个HTML文件将是一个噩梦来支持。 我到目前为止: 我的testrunner.js: var Mocha = require('mocha'), expect = require('expect.js'), fs = require('fs'), path = require('path'); var mocha = new Mocha( { ui: 'bdd' }); // I only add one file for now mocha.addFile( path.join(__dirname, 'tests_integration/test.js') ); mocha.run(function(failures){ process.on('exit', function () { process.exit(failures); }); }); 我的test.js:这是我奋斗的地方,因为我不知道如何在页面内运行testing: var […]

儿童大量使用后死亡

我正在执行大约15 000次的phantomjs脚本,一遍又一遍地用于不同的网页。 我正在使用自己创build的队列系统,所以我只用execFile方法运行2个进程。 (队列是如何生成/组成的,但是用sizeof测量的队列大小只有20mb左右) 过了一会儿,我的nodejs脚本开始把这个消息传回给我: { [Error: Command failed: /home/ec2-user/bot/node_modules/phantomjs/lib/phantom/bin/phantomjs /home/ec2-user/bot/phantomjs-script.js http://www.example.com/foo/bar ] killed: true, code: null, signal: 'SIGTERM', cmd: '/home/ec2-user/bot/node_modules/phantomjs/lib/phantom/bin/phantomjs /home/ec2-user/bot/phantomjs-script.js http://www.example.com/foo/bar' } 如果我然后重新启动脚本,它们从nodejs脚本的开头抛出。 如果我注销并重新login,那么在再次出现这些消息之前,我可以再运行该脚本,就像第一次运行该脚本一样。 对我来说,这听起来像一个内存/堆/垃圾收集问题。 但似乎无法find关于如何处理它的任何信息,除了确定使用多less内存的不同方法。 结论是脚本正在使用一个非常高的内存量,在20-500 MB之间,用memoryUsage测量 …最终导致这个错误被抛出: child_process.js:1155 throw errnoException(err, 'spawn'); ^ Error: spawn ENOMEM at exports._errnoException (util.js:746:11) at ChildProcess.spawn (child_process.js:1155:11) at exports.spawn (child_process.js:988:9) at Object.exports.execFile (child_process.js:682:15) at /home/ec2-user/bot/main.js:66:20 at worker […]

来自phantomJS的POST调用不会使服务器从咕噜声中运行

这是我的设置。 我有一个咕task任务,做2件事情:1)启动一个HTTP服务器监听某个端口2)触发另一个咕task任务 上面触发的grunt任务是在PhantomJS的test-index.html页面上运行testing的testem任务。 test-index.html页面在第一个grunt任务中启动服务器的端口上发送一个POST调用。 问题:POST调用不会打到我的服务器。 注意:如果我手动运行同一个服务器(不是从grunt)然后运行testinggrunt任务,POST调用命中服务器。 这里是代码: 咕task任务 grunt.registerMultiTask('coverage', 'Generates coverage reports for JS using Istanbul', function () { var server = http.createServer(function(req, resp) { resp.setHeader("Access-Control-Allow-Origin", "*"); console.log('Got something'); req.pipe(fs.createWriteStream('coverage.json')) resp.end(); }); var port = 7358; server.listen(port); // This task simply executes a command: `testem.js ci` grunt.task.run('testem').then(function() { server.close(); }); }); test-index.html(在某处) function onTestemLoad() { […]

无法在heroku上findphantomjs可执行文件

我在我的web应用程序中使用gem Watir。 当我的用户触发一个行动时,watir webdriver被打开,并且在涉及的网站上有报废和张贴。 我不希望我的用户在操作过程中看到浏览器,所以我正在使用phantomJS的ghostdriver使用watir,如下所示: http ://watirmelon.com/2013/02/05/watir-webdriver-with-ghostdriver-on -osx-headless-browser-testing /这个工作完美的地方,但是当我尝试在heroku部署使用它,我得到以下错误: Selenium::WebDriver::Error::WebDriverError (Unable to find phantomjs executable.): 然后,我试图添加nodeJS&phantomJS buildpack在这里指定有没有工作nodejs / phantomjs Heroku buildpack? 我在控制台中运行以下命令行: ➜ tennis-match git:(master) heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs.git –app we-tennis-staging Buildpack set. Next release on we-tennis-staging will use https://github.com/heroku/heroku-buildpack-nodejs.git. Run `git push heroku master` to create a new release using this buildpack. ➜ tennis-match git:(master) […]

为什么我不能降级npm包PhantomJS?

前段时间我安装了npm包phantomjs。 现在我的unit testing不工作。 PhantomJS浏览器不捕获。 我想降级软件包phantomjs的版本。 我发现,我可以通过npm uninstall phantomjs来删除npm uninstall phantomjs 。 我做了这个和控制台说,一切都很好。 我试过命令npm v phantomjs | grep version npm v phantomjs | grep version 。 它说phantomjs已经安装,它的版本是2.1.3。 看起来像phantomjs没有卸载。 我试图从我的项目中完全删除node_modules并再次编写安装命令: npm install 。 当我检查版本时,我得到了2.1.3。 在我的package.json phantomjs中描述为"phantomjs": "^1.9.19" 。 所以,我预计,版本将是>=1.9.19 < 2.0.0 。 那么,这是1.9.19。 我在> node_modules \ phantomjs \ package.json中手动检查了版本,它是1.9.19。 那么实际安装了哪个版本? 为什么在packages.json和命令npm v xxx版本不一样?

带有Phantom.JS和Pageres(节点模块)的WebPackconfiguration错误

我正在尝试导入名为“pageres”( https://github.com/sindresorhus/pageres )的节点包模块,该模块使用Phantom.JS截取用户定义的网页。 我使用NPM来成功安装pageres,但试图将模块导入到我的项目中时,会抛出“无法parsing模块”child_process“”,“无法parsing模块fs”和“无法parsing模块”净'”。 在研究这个问题时,我发现( https://github.com/cytoscape/cytoscape.js/issues/998 )的工作是将下面的代码片段添加到我的webpackconfiguration文件中: node: { fs: "empty", child_process: 'empty', net: 'empty' } 问题是,这样做明确了防止webpack编译我的代码的错误,但现在我的应用程序根本不呈现。 是否有任何解决方法可用来解决这个问题,任何人都可以解释为什么我以前用“无法解决模块”child_process“的错误来了? 附注:我正在使用React-Redux-Universal( https://github.com/erikras/react-redux-universal-hot-example )作为我的锅炉,因此React.JS正在处理我的视图。 Webpackconfiguration(位于下面的Universal-reduxconfiguration文件中): webpack: { /* // A list of libraries that do not change frequently between deploys // and are best served in the vendor bundle. Optional. // // Expects: Array */ // vendorLibraries: [], […]

节点 – 骑手未处理的拒绝评估

我正在尝试用Node-horseman编写一个基本的网页抓取工具,但是我在评估函数中遇到了CSSselect器的一些问题。 有些网站的评估函数工作得很好,但是对于其他的网站,Node会抛出一个错误。 例如: var Horseman = require('node-horseman'); var horseman = new Horseman(); function getTitle() { var title = $('.product-name-main h1').text(); return {title: title}; } horseman .userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0') .open('http://shtoraoptom.ru/pokryvalo-nazsu-gul-abrikosovyj-240-260-sm') .evaluate(getTitle) .then(function(title){ console.log(title); return horseman.close(); }); 这段代码会抛出一个错误: Unhandled rejection getTitle evaluate global code evaluateJavaScript@[native code] evaluate@phantomjs://platform/webpage.js:390:39 phantomjs://code/bridge.js:121:61 at Horseman.<anonymous> (/home/ubuntu/workspace/node_modules/node-horseman/lib/actions.js:839:38) at […]

Phantomjs应该不会发送cookie

我正在使用phantomjs,特别是phantom-prebuilt在npm查看我的节点快递应用程序提供的页面,但它不是发送cookie,尽pipe在同一个域名。 我怎样才能得到幻像正确发送cookies? var system = require('system'); var page = require('webpage').create(); phantom.addCookie({ domain: 'domain', name: 'ru.sid', value: 'aValue' }); console.log(JSON.stringify(phantom.cookies[0]); /* This is what is logged { domain: '.domain', httponly: false, name: 'ru.sid', path: '/', secure: false, value: 'aValue' } */ page.open('domain/anotherPath') //cookie is not sent

如何使用node-horseman获取html时解决这个错误?

我使用模块node-horseman horseman从节点运行PhantomJS。 我想从githublogin页面获取html。 这是我的代码。 var Horseman = require('node-horseman'); var horseman = new Horseman(); horseman .open('https://github.com/login') .html() .log() .close(); 但是我得到错误。 Unhandled rejection eval@[native code] evaluatePage global code evaluateJavaScript@[native code] evaluate@phantomjs://platform/webpage.js:390:39 phantomjs://code/bridge.js:121:61 at /Users/larry/Desktop/repos/getFollower/node_modules/node-horseman/lib/actions.js:989:36 at tryCatcher (/Users/larry/Desktop/repos/getFollower/node_modules/bluebird/js/release/util.js:16:23) at Function.Promise.fromNode.Promise.fromCallback (/Users/larry/Desktop/repos/getFollower/node_modules/bluebird/js/release/promise.js:178:30) at Horseman.<anonymous> (/Users/larry/Desktop/repos/getFollower/node_modules/node-horseman/lib/actions.js:987:29) at Horseman.tryCatcher (/Users/larry/Desktop/repos/getFollower/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/larry/Desktop/repos/getFollower/node_modules/bluebird/js/release/promise.js:504:31) at Promise._settlePromise (/Users/larry/Desktop/repos/getFollower/node_modules/bluebird/js/release/promise.js:561:18) at Promise._settlePromiseCtx (/Users/larry/Desktop/repos/getFollower/node_modules/bluebird/js/release/promise.js:598:10) at Async._drainQueue […]