casperjs screenshot returning blank square boxes. Please tell me possible solution to get the character instead of boxes - phantomjs

I am using CasperJS 1.1.0 with PhantomJs 2.0. I am using Linux server.
I have a script, trying to run and take screenshots.
This screenshot is fine for local server nor for live.
Screenshot of the site will look like this:
https://i.stack.imgur.com/dJe4L.png
So, instead of the actual letters, it renders square boxes.
var casper = require('casper').create({
verbose: true,
});
casper.options.waitTimeout = 40000;
casper.options.viewportSize = {width: 1200, height: 768};
phantom.cookiesEnabled = true;
casper.start('http://domain.com/', function() {
this.wait(5000, function () {
this.echo(this.getTitle());
this.capture("screenshot.png");
});
});
casper.run(function () {
this.exit(0);
});
Please tell me where i am wrong.

I would use waitForSelector on the items that you're wanting screenshots of, rather than the 5 second hard wait. Consider adding
verbose: true
waitTimeout:20000
Which will give you 20 second wait limit, longer than the 5 seconds default. Then, instead of your current wait, use something like:
this.waitForSelector('img', function() {
this.capture('test.png')
}
You can change the img selector to be something more specific, but waiting for the images themselves to load is a pretty certain way of making sure they will be captured. The reason we changed the timeout to 20 seconds is in case their site takes a little longer to load their images :)
Let me know if this doesn't help, happy to follow up. I will need examples of the site and the image you'd like though.
EDIT: Can confirm this works for me, let me know if it works for you.
var casper = require('casper').create({
verbose: true,
logLevel: 'error',
pageSettings: {
loadImages: true,
loadPlugins: true,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11'
},
clientScripts: ['vendor/jquery.min.js', 'vendor/lodash.js'],
viewportSize: {
width: 1600,
height:1000
},
});
casper.start('http://dev.bunkerbradleycouture.com/')
casper.then(function() {
this.waitForSelector('img', function() {
this.capture('test.png')
})
})
casper.run()

Related

createjs, soundjs, preloadjs Sound not working in Safari desktop Version 9.1.3, OSX 10.11.6

I have sound working in Chrome, Firefox on Mac, but not Safari Version 9.1.3, OSX 10.11.6.
I can only find a statement in the docs saying that Safari will need the Quicktime plugin. However, when I point my Safari to the Soundjs and Preloadjs demo pages, the sound works fine in the demos. Furthermore, apparently Apple is no longer including the QT plugin on current installs of Safari. It would be unacceptable to ask users to install a legacy plugin. (edit: just received word the sound isn't working in MS Edge either)
Here is all of my code:
var stage;
var canvas;
canvas = document.getElementById("gamezCanvas");
stage = new createjs.Stage(canvas);
var soundsManifest = [
{
id: 0, src: '10_ciiruhi.ogg'
},
{
id: 1, src: '20_shuuk.ogg'
}
];
var queue = new createjs.LoadQueue();
queue.installPlugin(createjs.Sound);
queue.on("complete", handleComplete);
queue.loadManifest(soundsManifest, true, audio_url);
function handleComplete() {
createjs.Sound.play(1,
{
interrupt: createjs.Sound.INTERRUPT_NONE,
loop: 0,
volume: 1
}
);
}
var btn = new createjs.Shape();
btn.graphics.beginFill("#000");
btn.graphics.drawRect(0, 0, 200, 120);
stage.addChild(btn);
stage.update();
btn.on("click", function() {
createjs.Sound.play(0,
{
interrupt: createjs.Sound.INTERRUPT_NONE,
loop: 0,
volume: 1
}
);
});
It was a simple file format issue. Outside the scope of createjs's documents to inform me about. Shame on me :(
OGG is no bueno in Safari and Exploder.

extjs Dynamically load nodes on scroll down

I am new to Ext Js 4.1, I have 5000 child nodes and need to load only 50 nodes on load,after scrolling down have to load another 50 nodes and continues. I am trying from past 2 days with different scenarios, but I didn't find anything related, can anu one please help me how to do, if possible with sample code.
Thanks in Advance
The only way to do this with a server that gives you your's 5000 child nodes is to use a buffered store.
Using a buffered store you can set your page dimensions and scrolling down changing the page you will be able to load your datas 50 by 50 records.
check all you need here http://docs.sencha.com/extjs/5.1/5.1.2-apidocs/#!/api/Ext.data.BufferedStore
buffered store disponible also on ext 4.1
also some examples on sencha examples
you can watch this
http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/infinite-scroll.html
Finally i find the solution that we need to use 'bufferedrenderer' Plugin.Infinite grid uses a buffered store, and is not supported for trees.
Here is the sample code
Ext.onReady(function () {
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'http://localhost/codig/index.php/user/jsonusers',
extraParams:limitValue
}
});
store.reload();
var treePanel = Ext.create('Ext.tree.Panel', {
id:'mytree',
title: 'Infinite nodes tree',
width: 200,
height: 400,
store: store,
rootVisible: false,
plugins: {
ptype: 'bufferedrenderer'
},
renderTo: Ext.getBody()
});
});

Concern regarding automation using Protractor

Am new to protractor. I found some errors while automating the URL using protractor. And I can access the URL manually and does not find any issues. Please find the code mentioned below and kindly clarify my concern.
Screenshot of cmd while executing the code
exports.config={
specs: ['try.js'],
//seleniumArgs: ['-browserTimeout=60']
capabilities:{
'browserName':'chrome',
},
baseUrl:'',
allScriptsTimeout:3000,
//getPageTimeout:5000,
framework:'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval:56000,
isVerbose: true,
}
}
spec: try.js
===========
describe('first try',function(){
var EW=protractor.ExpectedConditions;
beforeEach(function(done){
ignoreSynchronization=true;
browser.get('');
});
it('open PO',function(){
//clicking login button
var login=element(by.linkText('Login'));
browser.wait(EW.presenceOf(login),10000);
login.click();
//clicking open Po dashboard icon/link
var po=element(by.linkText('Open PO'));
browser.wait(EW.presenceOf(po),20000);
po.click();
//entering value 100 in the fiter field
var e=element.all(by.repeater('colFilter in col.filters')).get(00).element(by.tagName('input'));
browser.wait(EW.presenceOf(e),10000);
e.sendKeys(100);
//selecting the filterd values and printing it in console
element.all(by.repeater('col in colContainer.renderedColumns track by col.uid').column('Entity')).getText().then(console.log);
});
});
Make sure you have ng-app defined on all of your pages. Protractor requires it to run. If the page has redirects or just takes some time before it loads, try something like this:
browser.get(websiteUrl);
browser.wait(function () {
return browser.executeScript('return !!window.angular');
}, 10000, 'Error: Angular was not found on the page within ten seconds');
This will wait up to ten seconds for angular to load up, and fail if it is not there.

XMLHttpRequest in a ContentScript from the Firefox SDK (Cross-Domain)

I am porting a chrome extension to firefox and want to keep as much code as possible. I am working with the sdk and I am new with JavaScript, so please bear with me if it is just a nooby mistake ;)
I need to get some stuff via a couple of XMLHttpRequests in content-scripts.
The "firefox-way" of doing things would be to use the sdk-request-api and work via messages between the main- and the content-script like so. Besides the fact that it would mean a lot of work for me to implement this throughout the whole addon, I also need to get binary data, which seems not to be possible.
The workaround for this is documented here. I would prefer to avoid this, since I think I read somewhere that it is a beta-feature right now and it seems to be pretty "work-aroundy".
Ideally I would like to implement it this way. In the upcoming Firefox 24 it should be possible to allow content scripts to access certain domains. Therefore I am using Firefox Aurora right now. I added the following code to my package.json:
"permissions": {
"cross-domain-content": ["http://mozilla.org"]
}
My main.js creates a panel when a button is clicked and loads the scripts into it:
var testPanel = require("sdk/panel").Panel({
contentURL: data.url("pages/background.html"),
contentScriptFile: [data.url("util/jquery-1.8.2.min.js"), data.url("pages/xhrTest.js")]
})
testPanel.show();
And this is my xhrTest.js:
var xhr = new XMLHttpRequest();
xhr.open("GET","http://mozilla.org",true);
xhr.onerror = function () {
console.log("Error");
};
xhr.onload = function () {
console.log("loaded");
}
xhr.send();
While debugging, it jumps from status 2 to 4 with an empty response and calls the "onerror". The status is 0, statustext is empty and I don't see any other indicators of what went wrong.
Now I don't know if this is still the same-origin-policy blocking me, or if I did something else wrong?
I'd really appreciate any help I can get :)
Thanks in advance,
Fabi
Hrm, I can't really see a glaring error. Here is an example add-on based on the docs that does work, at least it does for me in Firefox 24 Beta:
Main.js:
// main.js
var data = require("sdk/self").data;
var panel = require("sdk/panel").Panel({
height: 250,
contentURL: data.url("panel.html"),
contentScriptFile: data.url("panel-script.js")
});
panel.on("show", function(){
panel.port.emit("show");
});
require("sdk/widget").Widget({
id: "test-widget",
label: "Test-Widget",
contentURL: "http://www.mozilla.org/favicon.ico",
panel: panel
});
Panel.html:
<!doctype HTML>
<html>
<meta charset="utf-8">
<head></head>
<body>
<pre id="forecast_summary"></pre>
</body>
</html>
Content script:
// panel-script.js
var url = "https://hn-test.firebaseio.com/articles/e5b10c82600b51732af584583a7f57c4a7c01bff.json";
self.port.on("show", function () {
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.onload = function () {
var element = document.getElementById("forecast_summary");
// formatting
var pretty = JSON.stringify(JSON.parse(request.responseText), null, ' ');
element.textContent = pretty;
};
request.send();
});
Package.json:
{
"name": "jp-crossdomain-xhr",
"fullName": "jp-crossdomain-xhr",
"id": "jid1-B2RaQxOBKox8wA",
"description": "a basic add-on",
"author": "",
"license": "MPL 2.0",
"version": "0.1",
"permissions": {
"cross-domain-content": ["https://hn-test.firebaseio.com"]
}
}
Github Repo

CasperJS/PhantomJS unable to open Facebook

I've seen examples such as this one showing how to login to facebook with casperJS:
How to login into a website with CasperJS?
but am unable to get this code to work for me. I'm not interested in the login portion, I just want to load any facebook page into casperjs or phantomjs but keep getting a fail on load.
Is this working for anyone else? or has facebook detected the browser and not allowing access anymore?
Here is a simplified version of what I am unable to do:
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings:{
userAgent :'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4' ,
loadImages: false, // The WebPage instance used by Casper will
loadPlugins: false // use these settings
}
});
casper.start()
casper.thenOpen('https://www.facebook.com/pfchangs', function() {
this.echo(this.getHTML());
//this just prints out empty page: <html><head></head><body></body></html>
});
casper.run();
I'm running this on Windows 7
Looks like this is known bug with casperjs windows batch file:
https://github.com/n1k0/casperjs/commit/0d659f140f1e2120bed967d8301657b5fe79f19c