phantomjs

Better way to integrate maven/qunit/phantomjs?

南楼画角 提交于 2019-12-03 04:24:55
问题 I have been investigating the best way to do JS unit testing in our maven CI environment. What I currently have cobbled together is the following in my maven project: qunit resources (JS/CSS files) qunit test html files (one for each file under test) with html fixture if required index html file which references the test html files as an ordered list of hyperlinks PhantomJS runner file, which: opens the index html file and parses out list of test files opens each test file takes a screenshot

CasperJS: Configure proxy options inside code

喜欢而已 提交于 2019-12-03 04:10:37
I was wondering how we could set cli parameters inside our code and not by placing them at the end of our command like this: casperjs casper_tor.js --proxy=127.0.0.1:9050 --proxy-type=socks5 I've tested things like that but it didn't work: var casper=require('casper').create(); casper.cli.options["proxy"] = "127.0.0.1:9050"; casper.cli.options["proxy-type"] = "socks5"; ... casper.run(); What I'm trying to achieve is to set new proxies inside my code and to scrap my new ip address from whatsmyip.com to check that everything is right (I'm writing bots that will frequently change their proxies).

PhantomJS using too many threads

故事扮演 提交于 2019-12-03 04:10:32
I wrote a PhantomJS app to crawl over a site I built and check for a JavaScript file to be included. The JavaScript is similar to Google where some inline code loads in another JS file. The app looks for that other JS file which is why I used Phantom. What's the expected result? The console output should read through a ton of URLs and then tell if the script is loaded or not. What's really happening? The console output will read as expected for about 50 requests and then just start spitting out this error: 2013-02-21T10:01:23 [FATAL] QEventDispatcherUNIXPrivate(): Can not continue without a

Phantomjs loads pages slowly

被刻印的时光 ゝ 提交于 2019-12-03 03:49:23
问题 I'm new into phantomjs, trying it on a standard centOS server (with httpd etc installed, but no modified settings apart from nameservers set to 8.8.8.8 and 8.8.4.4). I'm using the default loadspeed.js file (be it renamed). However, page speeds appear to be extremely slow. Here's an example: $ phantomjs phantomjs.js http://www.google.com/ starting Loading time 90928 msec $ phantomjs phantomjs.js http://173.194.67.138/ #(one of google's public ips) starting Loading time 30204 msec When I load

using mocha-phantomjs to automate functional testing

丶灬走出姿态 提交于 2019-12-03 03:43:40
问题 My project is using: Node, Coffeescript, SocketIO, Browserify and Mocha. (mocha for standard server-side unit tests) I would like to automate some client-side interface testing using a headless browser. PhantomJS looked like the ideal choice (picked over Zombie due to web socket support). The PhantomJS pages warn it is not a test runner, which I understand, and they recommend using the mocha-phantomjs project to drive your tests. So I've been able to get the sample tests running (e.g. mocha

How to render an html element using phantomjs

僤鯓⒐⒋嵵緔 提交于 2019-12-03 03:43:14
I want to save the image inside the div specified in the code. But using the code below i"m getting some other portion rendered. Is this the correct way to do it? I'm just a beginner in phantomjs. So Please help. var page = require('webpage').create(); page.open("http://n1k0.github.io/casperjs/#phantom_Casper_captureSelector", function (status) { if (status !== 'success') { console.log('Unable to load the address!'); } else { var clipRect = page.evaluate(function () { return document.querySelector(".span7 demo").getBoundingClientRect(); }); page.clipRect = { top: clipRect.top, left: clipRect

setInterval and this.wait in casper.js

99封情书 提交于 2019-12-03 03:41:16
I need to make a loop of 3 times and 2 seconds in between each iteration . I tried these 3 options: Option 1 var casper = require('casper').create({ verbose: false, logLevel: 'debug' }); casper.start("http://google.com"); casper.on('remote.message', function(msg) { this.echo('remote message caught: ' + msg); }) casper.thenEvaluate(function() { var x = 0; var intervalID = setInterval(function () { console.log("Using setInternal " + x); if (++x === 3) { window.clearInterval(intervalID); } }, 2000); }); casper.run(); Observation : Nothing appeared because the script ended right away before the

Getting remote debugging set up with PhantomJS

痞子三分冷 提交于 2019-12-03 03:37:12
问题 I'm trying to set up remote debugging with PhantomJS, without much luck. I am following the instructions at https://github.com/ariya/phantomjs/wiki/Troubleshooting. I have a little program named debug.js : var system = require('system' ), fs = require('fs'), webpage = require('webpage'); (function(phantom){ var page=webpage.create(); function debugPage(){ console.log("Refresh a second debugger-port page and open a second webkit inspector for the target page."); console.log("Letting this page

Generate pdf files phantomjs, repeating HEADER

ⅰ亾dé卋堺 提交于 2019-12-03 03:36:36
I'm generating pdf files using phantomjs but I would like to repeat a defined header with HTML, it works when there are no images but as soon I add it doesn't work page.viewportSize = { width: 600, height: 600 }; page.paperSize = { format: 'A4', orientation: 'portrait', margin: '0px', header: { height: "1.2cm", contents: phantom.callback(function(pageNum, numPages) { return '<img src="https://www.google.com.bo/images/srpr/logo4w.png" height="0.95cm"/>'; }) }, footer: { height: "0.7cm", contents: phantom.callback(function(pageNum, numPages) { return '<h3 class="header">Footer</h>'; }) } } Hacky

Java后端使用Freemarker导出word文档的各种细节

女生的网名这么多〃 提交于 2019-12-03 03:32:47
1.前言 最近在项目中,因客户要求,需要做一个导出成word的功能(比如月度报表等),技术选型也考虑过几种,比如easypoi,itext,但发现这两种在实现起来有困难,所以最终还是选Freemarker模板进行导出,灵活性比较好。 2.实现步骤 1.准备好标准文档的word,标题格式间距什么的先设计好,这是减少后面修改模板文很重要一步; 2.打开word原件把需要动态修改的内容替换成***,如果有图片,尽量选择较小的图片几十K左右,并调整好位置; 3.另存为,选择保存类型Word 2003 XML 文档(*.xml)【这里说一下为什么用Microsoft Office Word打开且要保存为Word 2003XML,本人亲测,用WPS找不到Word 2003XML选项,如果保存为Word XML,会有兼容问题,避免出现导出的word文档不能用Word 2003打开的问题】,还有保存的文件名尽量不要是中文; 4.用NotePad打开文件,notepad预先装好xml的插件,然后格式化,当然也可以用Firstobject free XML editor打开文件,选择Tools下的Indent【或者按快捷键F8】格式化文件内容。看个人喜欢; notepad xml插件下载地址: https://sourceforge.net/projects/npp-plugins/files/XML