phantomjs

How to catch new window opend by window.open(url, _blank) in PhantomJS?

谁都会走 提交于 2019-12-03 15:58:27
I'd like to check with PhantomJS whether my script correctly opens a new window/tab on click. The open is triggerd by a js event listener and opened through window.open(url, "_blank") . How can I listen for the new window with PhantomJS? There seem to be three ways to do this: onPageCreated CasperJS solves this by using page.onPageCreated . So when window.open is called in the page, a new page is created and page.onPageCreated is triggered with the newly created page. page.open(address, function (status) { if (status !== 'success') { console.log('Unable to load the address!'); phantom.exit();

Trying to set up Grunt to automate some testing, testing works fine in the browser but not at the command line

ⅰ亾dé卋堺 提交于 2019-12-03 15:34:34
I'm currently trying to incorporate GruntJS with a few plugins (PhantomJS Qunit and Connect plugins). However, setting up a simple test is throwing me errors and I can't find the solution despite a few days of searching. I'm using a local web server (MAMP) and the website is running on a CMS. Running the tests by accessing the test template in a browser works fine, but when trying to access the same tools via the command line using sudo grunt test PhantomJS return an odd error: Running "qunit:all" (qunit) task Testing http://user-guides:80/test/test.html Warning: PhantomJS timed out, possibly

Phantomjs not render hebrew fonts

大兔子大兔子 提交于 2019-12-03 15:33:08
I am using PhantomJs 1.9.2 on Centos 6.3 to for automated ui tests. When a test fails, screenshots are saved to the server. My problem is that even though the screenshots are saved, they do not contain readable fonts. So if the website reads like this: חיים טכנולוגיים the screenshot of the site will look like this: םםםםםםםםםםםםם So, instead of the actual letters, it renders and saves little boxes. The system is centos 6.3. Freetype and Fontconfig are also installed. How could I go about fixing this? Thanks! You should use python code for taking screenshots of website. there are two module

Is there a way to listen to an event in the phantom context from page context?

…衆ロ難τιáo~ 提交于 2019-12-03 14:37:18
问题 For example: I open a page with PhantomJS, evaluate an asynchronous script (e.g. ajax). When it succeeds, I want to let the phantom context (outside of page.evaluate() ) know that the asynchronous process is finished. I don't want to use setTimeout and setInteval to wait and check continously in the phantom context that the process is finished. 回答1: That is exactly what the onCallback and window.callPhantom() pair is for. So, if you have an asynchronous call in the page context like an AJAX

PhantomJS hangs for a long time saying “Asynchronous Sessions clean-up phase starting NOW”

点点圈 提交于 2019-12-03 14:24:52
问题 Here is a screenshot: task : Codeception PHP Testing Framework v1.6.2 Powered by PHPUnit 3.7.19 by Sebastian Bergmann. Suite selenium_acceptance started Trying to see the welcome page of newweather (welcomeCept.php) issue : it sits as it is and waiting for phantomJS to respond and below is what phantomJS screen is showing : [INFO - 2014-03-13T01:42:51.575Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: ca14e740-aa50-11e3-bb6b-75468ba86108 [INFO - 2014-03-13T01:47:42

Take screenshot from Karma while running tests in PhantomJS 2?

不羁岁月 提交于 2019-12-03 14:19:34
I need a way to take a screenshot during a test which uses QUnit and Karma to run inside PhantomJS 2.0.1 I've found this command: window.top.callPhantom('render'); That doesn't throw any error but doesn't seem to work, or at least, I don't know where to look for the taken screenshot. Any clue? Fez Vrasta Found a way! Solution I had to edit my custom PhantomJS custom launcher adding an option: PhantomJSCustom: { base: 'PhantomJS', options: { onCallback: function(data){ if (data.type === "render") { // this function will not have the scope of karma.conf.js so we must define any global variable

How can I see the HTTP status code from the request made by page.open?

怎甘沉沦 提交于 2019-12-03 14:15:50
I have a phantomJS script that contains the following: page.open(url, function (status) { if (status === "fail") { /* handle failure */ } }); The status check works sometimes, but the status will still be "success" even if the request returns 500. How can I get the actual request status code? Andrey Borisko You can do it something like this: var page = require('webpage').create(), system = require('system'), resources = []; page.open('http://google.com', function (status) { console.log('Loaded with http status:', resources[0].status); phantom.exit(); }); page.onResourceReceived = function

Exposing variables from PhantomJS call to injectJS

故事扮演 提交于 2019-12-03 14:05:01
I've followed examples for injecting jQuery from the getting started page and that works just fine. I have a local copy of jQuery in the same directory, and do something like... if(page.injectJs('jquery.min.js')) { page.evaluate(function(){ //Use jQuery or $ } } When I try to inject my own script(s), none of the functions are available to me. Say I have a script called myScript.js that just has function doSomething() { // doing something... } I cannot then use doSomething like... if(page.injectJs('myScript.js')) { console.log('myScript injected... I think'); page.evaluate(function() {

setInterval and this.wait in casper.js

邮差的信 提交于 2019-12-03 13:40:54
问题 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); } },

karma.conf.js automatic file ordering?

旧巷老猫 提交于 2019-12-03 13:33:30
I have a large angularjs project ordered by features. I'd like to setup unit testing but I'm having trouble getting the karma.conf.js file ordering setup. I tried specifying a simple glob pattern like **/*.js but many of my modules failed to load due to the ordering that they're included in Karma when ran. As I understand, it's alphabetical, first match. I was able to resolve this by manually figuring out the ordering by doing something like this: // list of files / patterns to load in the browser files: [ // External scripts 'bower_components/angular/angular.js', 'bower_components/angular