phantomjs

phantomjs throwing DOM exception 18 on canvas.toDataURL using src images

六月ゝ 毕业季﹏ 提交于 2019-12-01 17:32:36
I'm trying to convert svg to png images using phantomjs : var page = require('webpage').create(); page.evaluate(function() { var svg = '<svg class="tnt_tracks_svg" width="800" height="180" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/\ xlink"><rect width="10" height="10" fill="red"></rect></svg>'; var src = 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(svg))); var img = new Image(); img.src = src; img.onload = function() { var canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; var context = canvas

PhantomJS - 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive

浪尽此生 提交于 2019-12-01 17:18:35
I'm trying to change the value of a input with PHP webdriver and PhantomJS. When I run a simple $driver->executeScript("document.getElementById('changeme').value='".$newvalue."' ;", array()); I get the following error Refused to evaluate a string as JavaScript because unsafe-eval is not an allowed source of script in the following Content Security Policy directive I've got the following command line options set --ignore-ssl-errors=true --web-security=false --ssl-protocol=any Any suggestions? 来源: https://stackoverflow.com/questions/28593216/phantomjs-unsafe-eval-is-not-an-allowed-source-of

On PhantomJS I can't include jQuery and without jQuery I can't post form data

a 夏天 提交于 2019-12-01 17:13:36
I am having trouble running jQuery in PhantomJS. I have found this answer, which talks about no variable is available inside evaluate function but the question is about a node module and on my example I only call console.log inside evaluate function. I have put this question on GitHub too . Previously, for some pages, the following evaluate code didn't execute. Now that @b1f56gd4 has provided some help, it now prints messages; I can't execute it but now I can see this: The page at https://login.yahoo.com/ ran insecure content from http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js

PhantomJS does not work with Karma in Angular2 project

倾然丶 夕夏残阳落幕 提交于 2019-12-01 16:21:14
I have created an out-of-the box project with the angular cli (1.0.0-rc1.0.0). Then I installed the PhantomJS plugin ( npm install karma-phantonjs-launcher ). Reproduction steps: create project with angular2 cli ( ng new TestPhantomJS ) run npm install karma-phantonjs-launcher in the karma.conf file add PhantomJS, ie change to browsers: ['Chrome'] this browsers:['Chrome', 'PhantomJS'] Reason beeing that for Team City integration I need a headless browser. The test run OK with ng test as long as the Chrome is specified as the browser, The problem is when you try and use PhantomJS. You will get

phantomjs throwing DOM exception 18 on canvas.toDataURL using src images

孤街醉人 提交于 2019-12-01 16:12:39
问题 I'm trying to convert svg to png images using phantomjs: var page = require('webpage').create(); page.evaluate(function() { var svg = '<svg class="tnt_tracks_svg" width="800" height="180" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/\ xlink"><rect width="10" height="10" fill="red"></rect></svg>'; var src = 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(svg))); var img = new Image(); img.src = src; img.onload = function() { var canvas =

How can I use google web fonts with phantomjs

不羁的心 提交于 2019-12-01 16:00:46
I'm using phantomjs version 1.9.7 which I believe is supposed to support web fonts. I have inserted the font with google web fonts however it is just displaying my fallback font when I automate a screengrab. The webfont is displaying fine in all my browsers. Are there any workarounds for this? I have struggled with this issue for several hours. Well, there is a simple reason for this controversy: user-agent ! Some services such as Google Fonts are returning different CSS content based on user-agent. When you call a webpage which includes Google Fonts with default PhantomJs user-agent, Google

PhantomJS not rendering screenshots with webfonts?

↘锁芯ラ 提交于 2019-12-01 15:58:46
So I have been looking around and can't seem to find a solution on how to get PhantomJS to actually display webfonts on screenshots, can anyone tell me if there is a way to do this? I have been testing and testing for about a week now and finally came up with the answer, know that this might also be a result of me running PhantomJS on a Windows machine. I am currently running PhantomJS v1.9.7 and have found the following solution: Using this in my CSS file: @font-face { font-family: 'Vampiro One'; src: url(http://themes.googleusercontent.com/static/fonts/vampiroone/v3/Ho2Xld8UbQyBA8XLxF1

How do you create a browser profile for Selenium's PhantomJS/GhostDriver?

≯℡__Kan透↙ 提交于 2019-12-01 15:22:23
Here's how you create a Firefox profile: fp = webdriver.FirefoxProfile() fp.set_preference("browser.download.folderList",2) fp.set_preference("browser.download.dir", download_dir) fp.set_preference("browser.download.manager.showWhenStarting",False) fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv") How do you do it with PhantomJS (GhostDriver)? luksch The closest you can get with phantomjs is to use the driver capabilities: DesiredCapabilities caps = DesiredCapabilities.phantomjs(); caps.setCapability( "phantomjs.page.settings.userAgent", "Mozilla"); Set<String> cliArgs =

On PhantomJS I can't include jQuery and without jQuery I can't post form data

一曲冷凌霜 提交于 2019-12-01 15:03:42
问题 I am having trouble running jQuery in PhantomJS. I have found this answer, which talks about no variable is available inside evaluate function but the question is about a node module and on my example I only call console.log inside evaluate function. I have put this question on GitHub too. Previously, for some pages, the following evaluate code didn't execute. Now that @b1f56gd4 has provided some help, it now prints messages; I can't execute it but now I can see this: The page at https:/

Chinese characters showing as question marks

大憨熊 提交于 2019-12-01 14:55:17
This has been asked before, but I can't figure out what's wrong. I'm printing pdfs using phantomjs .render() . The rendered page is basically a local static site with these properties: <meta charset="UTF-8"> font: normal 17px helvetica,arial,verdana,sans-serif running and tested on Windows locally and Azure Worker Roles Chinese language pack installed and working when printing the same page from Chrome (Installed fonts e.g. Arial Unicode MS, SimSun ...) Latin characters are all fine, just Chinese ones are displayed as "?" For example I also tried the entire page in Arial or SimSun only, but no