phantomjs

How to run QUnit test and get back test result in C# via JavaScript callback?

两盒软妹~` 提交于 2019-12-03 08:55:26
In my several projects, I use MVC pattern for separating code (of concerns) into 3 tiers. Both of Model and Control tiers run on C# so I use testing framework like MSTest or NUnit to validate functional requirement for these tiers. For View tiers, I use QUnit to test JavaScript files. However, I cannot execute QUnit as automated test because MSTest doesn't directly support for testing web page. I need to run it in MSTest like the following logic. [TestMethod] public void JavaScriptTest() { var result = QUnit.Test('~/QUnit/test1.htm'); Assert.IsTrue(result.Failed <= 0) } Solution must use

How to read an image from phantomjs stdout in nodejs to serve it?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: There's probably some detail that I'm missing, because the rasterization script works fine standalone, but I haven't been successful reading its output from NodeJS so far. Here's the NodeJS part: var http = require('http'); var qs = require('querystring'); var fs = require('fs'); var spawn = require('child_process').spawn; var SCRIPT = fs.readFileSync('./script.js', { encoding: 'utf8' }); http.createServer(function (request, response) { var body = ''; request.on('data', function (data) { body += data; }); request.on('end', function () { var

PhantomJS change webpage content before evaluating

Deadly 提交于 2019-12-03 08:46:05
问题 I'd like to either remove an HTML element or simply remove first N characters of a webpage before evaluating/rendering it. Is there any way to do that? 回答1: It depends on multiple scenarios. I will only outline the steps for each combination of the answers to the following questions. Is the piece of JS called onload ( ol ) or is the script block immediately evaluated ( ie )? Is it an inline script ( is ) or is the script loaded separately (src attribute) ( ls )? Does the script block also

PhantomJS and clicking a form button

久未见 提交于 2019-12-03 08:42:30
I have a very simple HTML form that I'm attempting to test with various kinds of data. I wrote a prototype proof-of-concept in MS Access/VBA using the IE object. It worked fine but the finished testing product has to use PhantomJS. I've got the page-interfacing to work and the form is populating just fine. Where I'm stuck is getting the submit button to fire. I've combed through S.O. and tried all suggestions and nothing is working. I'm using PhantomJS 1.9.7 and using straight JavaScript test scripts. I tried various JavaScript techniques to fire the submit button. To satisfy the "Just use

Unable to load page resources with PhantomJS

半世苍凉 提交于 2019-12-03 08:35:13
I'm using PhantomJS to get page content for given URL. The problem is that on some pages PhantomJS can not load some resources (js, css...), and the error I'm getting is: error code 5, Operation canceled Web page on which I can reproduce this problem is www.lifehacker.com The resources I can not get are: http://x.kinja-static.com/assets/stylesheets/tiger-4ee27d6612a71ee3c68440f8e9c0025c.css http://c.amazon-adsystem.com/aax2/amzn_ads.js and some others too... The command I'm running is: phantomjs --debug=true --cookies-file=cookies.txt --ignore-ssl-errors=true --ssl-protocol=tlsv1 fetchpage.js

phantomjs with nohup not working

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I was trying to run phantomjs script via ssh using nohup command . But nohup threw an error which i found in nohup.out file. My command was --> nohup phantomjs example.js & phantomjs example.js run perfectly without nohup . I have also created a bash script to run this command with nohup but both time, I got this error --> events.js:72 throw er; // Unhandled 'error' event ^ Error: EBADF, read ** code of example.js var page = require('webpage').create(), system = require('system'), address, output, size; if (system.args.length < 3 || system

How to handle PDF pagination in PhantomJS

我是研究僧i 提交于 2019-12-03 08:20:16
问题 I am using PhantomJS to create PDFs from html. It works fine, but I can't find out how to work with pagination; I want to create a page for each div in my document, but I can't find anything in the doc. about pagination. If my document is short, it makes only one page, and if it is bigger, it creates one second empty page and my contents are in the first page which becomes very long. Any idea ? (I am using phantomJS-node module for nodeJS) 回答1: PhantomJS takes care of webkit’s css

Running phantomjs from a Ruby on Rails application

二次信任 提交于 2019-12-03 07:50:27
问题 I'm interested in using Phantomjs and I'd like to run it from my Ruby on Rails application. However, this is a command line tool (i.e. I'd need to run something like phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png in my terminal). How would I execute a command line tool from my app? 回答1: Use backticks in your ruby code e.g.: output = `phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png` 来源: https://stackoverflow.com/questions/6443945/running-phantomjs

Can't launch PhantomJS with Python in Windows 7

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to use PhantomJS with Python in my Windows 7, but is not working! Here what i tried to do. First, i installed webdriver. In the following code Firefox opens normally, so i believe webdrive is correctly installed. from selenium import webdriver browser = webdriver . Firefox () browser . get ( 'http://seleniumhq.org/' ) Then, i downloaded PhantomJS from the official website, unpacked it and put it in c:\Phantomjs. Then i added it in Environment Variables. Here what is in there: C:\Phantom\phantomjs-2.0.0-windows\bin So,

How to use Phantomjs' cookie API?

萝らか妹 提交于 2019-12-03 07:48:35
问题 I am trying to use rasterize.js from the phantomjs' exmaple folder to capture a web page into PDF. The problem I am having is that the web page requires user log in. Then I saw there is a cookie option for Phantomjs. The web site is Django powered just in case it matters. So I logged into the site manfully, opened the firebug, and typed document.cookie in firebug. I got the cookie settings and put into my cookies.txt. [http://localhost:7000] csrftoken: f3da886168fae33b840e7f6c93240dff