casperjs workaround for url=about:blank willNavigate=true, isMainFrame=false - phantomjs

I'm stuck on a page which returns 4 lines like this and then hangs up:
[debug] [phantom] opening url: https://xxx, HTTP GET
[debug] [phantom] Navigation requested: url=https://xxx, type=Other, willNavigate=true, isMainFrame=true
[info] [phantom] Step anonymous 3/6: done in 170ms.
[debug] [phantom] url changed to "https://xxx"
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
I launch the command this way, since I read about several ssl related bugs, and it works for the whole website xxx:
casperjs --ignore-ssl-errors=true --ssl-protocol=any script.js
My code is not nested since it's generated by my own class. However it's quite simple:
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7');
casper.start().then(function() {
this.open('https://xxx', {
headers: {
'Accept': 'text/html'
}
});
});
casper.then(function () {
this.viewport(1920, 1080);
});
casper.wait(
3000,
function () {
this.echo('timeout occured');
}
);
casper.then(function() {
this.capture('capture.png', {
top: 0,
left: 0,
width: 1920,
height: 1080
});
});
casper.run();
I need a hint by an expert, unluckily I'm not. Thank you in advance

Fixed in phantomjs 1.9.8, dont trust apt-get regular source (1.9.0-1) and guides around. Don't use 2.00 if you coupled it with casperjs, since is not supported.
Instructions for UBUNTU, for CENTOS replace apt-get with yum.
sudo apt-get update
apt-get install python
apt-get install ttf-mscorefonts-installer
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev
export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

Related

"ChromeHeadless have not captured in 60000 ms, killing." occuring only in Gitlab hosted CI/CD pipeline

When running a CI/CD pipeline on Gitlab, my Karma tests are timing out with the error:
ℹ 「wdm」: Compiled successfully.
05 08 2019 22:25:31.483:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9222/
05 08 2019 22:25:31.485:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency 1
05 08 2019 22:25:31.488:INFO [launcher]: Starting browser ChromeHeadless
05 08 2019 22:26:31.506:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
05 08 2019 22:26:31.529:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
05 08 2019 22:27:31.580:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
05 08 2019 22:27:31.600:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
05 08 2019 22:28:31.659:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
05 08 2019 22:28:31.689:ERROR [launcher]: ChromeHeadless failed 2 times (timeout). Giving up.
npm ERR! Test failed. See above for more details.
This problem does not occur when running tests locally, and it does not occur when running the tests using the same Docker image with Gitlab Runner locally.
I feel like I have tried every possible configuration with karma.conf.js. I have Googled this issue relentlessly and have tried every suggestion from proxy servers, to environment variables, to flags... but alas, no luck. I have tried multiple Docker images as this was initially failing on local Gitlab Runner but I have found that the Docker image selenium/standalone-chrome:latest works fine in local Gitlab Runner.
Here is my karma.conf.js file:
const process = require('process');
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
frameworks: [ 'jasmine' ],
// list of files / patterns to load in the browser
files: [
'src/**/*.spec.js'
],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
preprocessors: {
'src/**/*.spec.js': [ 'webpack' ]
},
webpack: {
// webpack configuration
mode: 'development',
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['env']
}
}
]
},
stats: {
colors: true
}
},
// test results reporter to use
reporters: [ 'spec' ],
// web server port
port: 9222,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// plugins for karma
plugins: [
'karma-chrome-launcher',
'karma-webpack',
'karma-jasmine',
'karma-spec-reporter'
],
// start these browsers
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--no-sandbox',
'--disable-gpu'
]
}
},
captureTimeout: 60000,
browserDisconnectTolerance: 5,
browserDisconnectTimeout : 30000,
browserNoActivityTimeout : 30000,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 1
})
}
And here is my .gitlab-ci.yml file:
.prereq_scripts: &prereq_scripts |
sudo apt -y update && sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo bash && sudo apt -y install nodejs
image: 'selenium/standalone-chrome:latest'
stages:
- test
test:
stage: test
script:
- *prereq_scripts
- npm install
- npm test
I am expecting the tests to run successfully in all three instances (local npm, local Gitlab Runner and remote Gitlab CI/CD pipeline). Currently it only runs in successfully in the first two.
In your karma.conf.js file you need to declare the CHROME_BIN variable inside the module.exports function:
module.exports = function(config) {
const process = require('process');
process.env.CHROME_BIN = require('puppeteer').executablePath();
config.set({
...
Currently, Puppeteer has an issue with Karma on Linux machines, see GitHub issue
There are plenty of solutions on how to make it works without Puppeteer if you use it just to install Headless Chromium.
I have installed it on my Jenkins Alpine machine using only two bash lines:
apk add chromium
export CHROME_BIN=/usr/bin/chromium-browser
Alternatively, you can use Docker with the same setup. One of the examples is here
Docker image with chromeheadless
for example, use a docker image of angular/ngcontainer with chrome headless for testing UI apps.
image: 'angular/ngcontainer:latest'
Also, I created one docker image with the latest chrome
image: 'anulals/angular'
https://hub.docker.com/r/angular/ngcontainer
https://hub.docker.com/r/anulals/angular

Testing React Apps with Phantom/Casper

I'm diving into functional testing and attempting to get a few simple tasks working. The app is built in ReactJS and I've decided to use Phantom/Casper. The problem is that even the most basic tasks fail.
In short, is there a trick for testing React apps with Phantom/Casper?
I've installed Phantom (v.2.1.1) and Casper (v1.1.0-beta5). As a first attempt I created a simple script to capture an image:
capture.js
var casper = require('casper').create({
viewportSize: {
width: 1024,
height: 768
},
verbose: true,
logLevel: "debug"
});
casper.start('http://localhost:9494', function() {
console.log("page loaded");
});
casper.then(function() {
this.capture('img.png');
});
});
casper.run();
Then run the script:
> casperjs capture.js
Viewing localhost:9494 in my browser pulls up the app as it should. But the resulting capture() image is a blank screen.
I've also tried adding a wait(), waitForSelector() and waitForResource() to no avail.
Here's the output in the console:
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: http://localhost:9494/, HTTP GET
[debug] [phantom] Navigation requested: url=http://localhost:9494/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "http://localhost:9494/"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2 http://localhost:9494/ (HTTP 200) page loaded
[debug] [phantom] Capturing page to /path/to/img.png
[info] [phantom] Capture saved to /path/to/img.png
[info] [phantom] Step anonymous 2/2: done in 848ms.
[info] [phantom] Done 2 steps in 848ms
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"
You need to add the babel-polyfill NPM package to your project (or any other version of the polyfill) and then in your main index.js(x) entry point for your app, include this line at the top:
import 'babel-polyfill';
We were having the exact same issue you are experiencing and this fixed it for us.
We had tried injecting the babel polyfill as part of the Casper test suite, but it was not working.
Not sure how you did the waiting. Make sure your capture is in the wait callback. I usually use code like this and it often happens that you need to adjust the waiting time to see results.
3 seconds is usually enough to crawl public websites, that's how I use it.
casper.then(function() {
this.wait(3000, function() {
this.capture('foo.jpg', undefined,
{
format: 'jpg',
quality: 75
});
});
});

click link without ID or Class with casperJS

I'm trying to get the list of links on the menu on the left on this page: http://www.hpenterprisesecurity.com/vulncat
the first thing I'm trying to do is click the "Expand All" link (on the top left corner) so the list gets expanded.
I have tried multiple ways to use the Xpath in different ways with no success on this page, this was my last try:
casper.start('http://www.hpenterprisesecurity.com/vulncat', function() {
casper.wait(5000);
this.echo("---------- TITLE: ");
this.echo(this.getTitle());
});
casper.thenClick(x('//*[#id="theContentCenter"]/div/p/a[1]/strong[contains(text(),"Expand")]'),function(){
casper.wait(5000,function(){
casper.capture("expanded.png");
});
});
Maybe since the page lacks Ids and Tags for most elements my approach won't work?
Thanks
the set-up:
casper = require('casper').create({
verbose:true,
logLevel:"debug"
});
casper.userAgent('Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405');
casper.viewport = {width: 1280, height: 720};
var x = require('casper').selectXPath;
phantomjs: 1.9.8
casperjs: 1.1.0-beta3
RESOURCE ERROR:
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[info] [phantom] Starting...
[info] [phantom] Running suite: 4 steps
[debug] [phantom] opening url: http://www.hpenterprisesecurity.com/vulncat, HTTP GET
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html"
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/header.html, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/all.html, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/intro.html, type=Other, willNavigate=true, isMainFrame=false
ResourceError: {
"errorCode": 203,
"errorString": "Error downloading http://www.hpenterprisesecurity.com/vulncat/en/vulncat/css/frame.css - server replied: Not Found",
"id": 7,
"url": "http://www.hpenterprisesecurity.com/vulncat/en/vulncat/css/frame.css"
}
ResourceError: {
"errorCode": 2,
"errorString": "Connection closed",
"id": 9,
"url": "http://www.fortifysoftware.com/images/gui/maincontent.level3.h1.bg.png"
}
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/4 http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html (HTTP 200)
---------- TITLE:
A Taxonomy of Coding Errors that Affect Security
[info] [phantom] Step anonymous 2/4: done in 770ms.
[info] [phantom] Step _step 3/5 http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html (HTTP 200)
[info] [phantom] Step _step 3/5: done in 770ms.
[info] [phantom] wait() finished waiting for 5000ms.
[info] [phantom] Step _step 4/5 http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html (HTTP 200)
[debug] [phantom] Mouse event 'mousedown' on selector: xpath selector: //*[#id="theContentCenter"]/div/p/a[1]/strong[contains(text(),"Expand")]
CasperError: Cannot dispatch mousedown event on nonexistent selector: xpath selector: //*[#id="theContentCenter"]/div/p/a[1]/strong[contains(text(),"Expand")]
/usr/lib/node_modules/casperjs/modules/casper.js:1355 in mouseEvent
/usr/lib/node_modules/casperjs/modules/casper.js:462 in click
/usr/lib/node_modules/casperjs/modules/casper.js:1793 in _step
/usr/lib/node_modules/casperjs/modules/casper.js:1553 in runStep
/usr/lib/node_modules/casperjs/modules/casper.js:399 in checkStep
Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///usr/lib/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match.
Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///usr/lib/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match.
Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///usr/lib/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match.

Casperjs script runs on OSX but not Windows

Phantomjs version - 1.9.7
Casperjs version - 1.1.0-beta3
This is the code
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
});
casper.start('https://www.gmail.com', function() {
casper.wait(3000, function() {
this.capture('gmail.png');
});
});
casper.run(function() {
this.exit();
});
The logs on Windows show
casperjs --ssl-protocol=any --ignore-ssl-errors=true login.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://www.gmail.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.gmail.com/, type=Other, willNavigate=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail: https://www.gmail.com/
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2: done in 349ms.
[info] [phantom] Step _step 3/3: done in 371ms.
[info] [phantom] wait() finished waiting for 3000ms.
[debug] [phantom] Capturing page to C:/Users/username/Desktop/gmail.png
[info] [phantom] Capture saved to C:/Users/username/Desktop/gmail.png
[info] [phantom] Done 3 steps in 3408ms
On OSX it shows the following
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://www.gmail.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.gmail.com/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://mail.google.com/mail/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1"
[debug] [phantom] Navigation requested: url=https://accounts.youtube.com/accounts/CheckConnection?pmpo=https://accounts.google.com&v=-320444755&timestamp=1420230909413, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2 https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1 (HTTP 200)
[info] [phantom] Step anonymous 2/2: done in 1398ms.
[info] [phantom] Step _step 3/3 https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1 (HTTP 200)
[info] [phantom] Step _step 3/3: done in 1418ms.
[info] [phantom] wait() finished waiting for 3000ms.
[debug] [phantom] Capturing page to /Users/username/code/casperjs/gmail.png
[info] [phantom] Capture saved to /Users/username/code/casperjs/gmail.png
[info] [phantom] Done 3 steps in 4511ms
The code is the same on both platforms, I have tried various combinations of --ignore-ssl-errors etc with no luck. Any suggestions?
Based on Artjom B.'s suggestions, I have updated the code like this -
var webPage = require('webpage');
var page = webPage.create();
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings: {
userAgent: 'Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1'
}
});
casper.on('resource.error', function(resource) {
this.echo('Error: ' +msg, 'ERROR'); });
casper.on("page.error", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
});
page.onResourceTimeout = function(request) {
console.log('Response (#' + request.id + '): ' + JSON.stringify(request));
};
casper.on("remote.message", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
});
casper.start('https://www.gmail.com', function() {
casper.wait(3000, function() {
this.capture('gmail.png');
});
});
casper.run(function() {
this.exit();
});
This gives the same result -
C:\Users\username\Desktop>casperjs --ssl-protocol=any --ignore-ssl-errors=true pt-login.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://www.gmail.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.gmail.com/, type=Other, willNavigate=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail: https://www.gmail.com/
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2: done in 338ms.
[info] [phantom] Step _step 3/3: done in 361ms.
[info] [phantom] wait() finished waiting for 3000ms.
[debug] [phantom] Capturing page to C:/Users/username/Desktop/gmail.png
[info] [phantom] Capture saved to C:/Users/username/Desktop/gmail.png
[info] [phantom] Done 3 steps in 3462ms

Casper JS : Strange error: status=fail (HTTP 200)

I'm trying to load the following webpage with casperjs/phantomjs http://m.10bet.com/#leage_panel#10096.
Therefore I wrote the following simple casper script:
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});
if( casper.cli.args.length != 1 )
casper.echo('No URL as arguments given. Exiting.\n').exit();
var id = casper.cli.args[0]
casper.start( 'http://m.10bet.com/#leage_panel#' + id, function() {
casper.waitForResource("http://m.10bet.com/pagemethods.aspx/UpdateEvents", function() {
this.echo(casper.getPageContent())
}, function(){}, function(){}, 10000 );
});
casper.run(function() {
this.echo('Done.').exit();
});
So, I'm waiting for the last resource to be loaded which is in this case "http://m.10bet.com/pagemethods.aspx/UpdateEvents". I checked this with the chrome developer tools. Subsequently I want to output the rendered html on the console.
However, but instead of the html I get a in my opinion very strange error:
solaris:js_loaders Tom$ casperjs 10bet_loader.js 10096
2014-01-03 17:31:36.545 phantomjs[8733:130b] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: http://m.10bet.com/#leage_panel#10096, HTTP GET
[debug] [phantom] Navigation requested: url=http://m.10bet.com/#leage_panel#10096, type=Other, lock=true, isMainFrame=true
[debug] [phantom] url changed to "http://m.10bet.com/#leage_panel#10096"
[debug] [phantom] Navigation requested: url=http://m.10bet.com/#leage_panel#10096, type=Reload, lock=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail (HTTP 200): http://m.10bet.com/#leage_panel#10096
[debug] [phantom] Successfully injected Casper client-side utilities
[debug] [phantom] url changed to "http://m.10bet.com/#leage_panel#10096"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step 2/2 http://m.10bet.com/#leage_panel#10096 (HTTP 200)
[info] [phantom] Step 2/2: done in 761ms.
[info] [phantom] Step 3/3 http://m.10bet.com/#leage_panel#10096 (HTTP 200)
[info] [phantom] Step 3/3: done in 771ms.
[warning] [phantom] Casper.waitFor() timeout
[info] [phantom] Done 3 steps in 790ms
Done.
solaris:js_loaders Tom$
As you can see from the log the error "Loading resource failed with status=fail (HTTP 200): http://m.10bet.com/#leage_panel#10096" gives a http 200 ok but failed. Eventually the webpage is not loaded or printed on the console. So I'm wondering what is going wrong here?
Usage:
casperjs stackoverflow.js --idEvent=10096
Code:
var casper = require('casper').create ({
waitTimeout: 15000,
stepTimeout: 15000,
verbose: true,
viewportSize: {
width: 1024,
height: 768
},
pageSettings: {
"userAgent": 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.10 (KHTML, like Gecko) Chrome/23.0.1262.0 Safari/537.10',
"loadImages": false,
"loadPlugins": false,
"webSecurityEnabled": false,
"ignoreSslErrors": true
},
onWaitTimeout: function() {
casper.echo('Wait TimeOut Occured');
},
onStepTimeout: function() {
casper.echo('Step TimeOut Occured');
}
});
//vars
var idEvent = casper.cli.get('idEvent');
// start
casper.start();
// check args
casper.then(function() {
if (!idEvent) {
//usage check
this.echo('Invalid usage: Must supply Event Id');
casper.exit();
}
});
casper.thenOpen('http://m.10bet.com/#leage_panel#' + idEvent, function() {
casper.waitForResource('http://m.10bet.com/pagemethods.aspx/UpdateEvents', function() {
//casper.waitForSelector('#league_block', function() {
}, function then() { //selector found
this.echo(casper.getPageContent());
casper.exit();
}, function timeout() { //selector not found
this.echo("Timeout On Selector...Exiting").exit();
});
});
// executes
casper.run();
Does your arguments work in other scripts? I'm curious because the documentation shows that arguments are referenced in this way.
casper.echo(casper.cli.has(0));
I'm wondering if maybe this is the issue?