Casperjs ne fonctionne pas comme prévu sur la machine Windows

J'ai un script casperjs qui donne le résultat souhaité lorsque je cours sur un serveur linux, mais quand je cours le même depuis mon ordinateur portable, cela ne fonctionne pas.

Comment dois-je déboguer? Les journaux du travail:

[info] [phantom] Starting... [info] [phantom] Running suite: 3 steps [debug] [phantom] opening url: http://caspertest.grsrv.com/, HTTP GET [debug] [phantom] Navigation requested: url=http://caspertest.grsrv.com/, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app/, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/" [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app/#/auth, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/#/auth" [debug] [phantom] Successfully injected Casper client-side utilities [info] [phantom] Step anonymous 2/3 https://caspertest.grsrv.com/my_app/#/auth (HTTP 200) [info] [remote] attempting to fetch form element from selector: 'form' [debug] [remote] Set "null" field value to test [debug] [remote] Set "null" field value to **** [debug] [phantom] Capturing page to /home/grsrvadmin/gs/casper/ss.png [info] [phantom] Capture saved to /home/grsrvadmin/gs/casper/ss.png [debug] [phantom] Mouse event 'mousedown' on selector: input[id="loginButton"] [debug] [phantom] Mouse event 'mouseup' on selector: input[id="loginButton"] [debug] [phantom] Mouse event 'click' on selector: input[id="loginButton"] [info] [phantom] Step anonymous 2/3: done in 1556ms. [info] [phantom] Step _step 3/3 https://caspertest.grsrv.com/my_app/#/auth (HTTP 200) [info] [phantom] Step _step 3/3: done in 1569ms. [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app/#/agreement/r8moskcfv7c80gpcd40fl12nmpf9e0nb, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/#/agreement/r8moskcfv7c80gpcd40fl12nmpf9e0nb" [debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/#/agreement/r8moskcfv7c80gpcd40fl12nmpf9e0nb" [info] [phantom] waitFor() finished in 217ms. [info] [phantom] Step anonymous 4/4 https://caspertest.grsrv.com/my_app/#/agreement/r8moskcfv7c80gpcd40fl12nmpf9e0nb (HTTP 200) [debug] [phantom] Mouse event 'mousedown' on selector: input[id="aggr_actionAccept"] [debug] [phantom] Mouse event 'mouseup' on selector: input[id="aggr_actionAccept"] [debug] [phantom] Mouse event 'click' on selector: input[id="aggr_actionAccept"] [info] [phantom] Step anonymous 4/4: done in 1813ms. [info] [phantom] Done 4 steps in 1826ms [debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] url changed to "about:blank" 

Connexion à la machine Windows:

 [info] [phantom] Starting... [info] [phantom] Running suite: 3 steps [debug] [phantom] opening url: http://caspertest.grsrv.com/, HTTP GET [debug] [phantom] Navigation requested: url=http://caspertest.grsrv.com/, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app/, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/" [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app/#/auth, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/#/auth" [debug] [phantom] Successfully injected Casper client-side utilities [info] [phantom] Step anonymous 2/3 https://caspertest.grsrv.com/my_app/#/auth (HTTP 200) [info] [remote] attempting to fetch form element from selector: 'form' [debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] url changed to "about:blank" 

Scénario:

 var casper = require('casper').create ({ waitTimeout: 60000, stepTimeout: 60000, verbose: true, logLevel: "debug", viewportSize: { width: 1366, height: 768 }, pageSettings: { "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0", "loadImages": true, "loadPlugins": true, "webSecurityEnabled": false, "ignoreSslErrors": true }, onWaitTimeout: function() { casper.echo('Wait TimeOut Occured'); }, onStepTimeout: function() { casper.echo('Step TimeOut Occured'); } }); casper.start('http://caspertest.grsrv.com/', function() { this.fillSelectors('form', { 'input[id="userName"]': 'test', 'input[id="userPassword"]': 'test', }, false); this.capture('ss.png'); this.click('input[id="loginButton"]') }); casper.waitForSelector('#aggr_actionAccept', function() { this.click('input[id="aggr_actionAccept"]') }); 

Voici comment j'exécute:

casperjs --ignore-ssl-errors=true test.js

La ressource est avec un client et j'utilise un VPN sur ma machine Windows pour accéder à la ressource sur mon navigateur. La machine linux sur laquelle il fonctionne est avec le client lui-même

Ajouter un gestionnaire d'événements resource.error :

 casper.on("resource.error", function(resourceError){ console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')'); console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString); }); 

Il semble, c'est un bug connu de PhantomJS (Correction en version 2.5 beta).
Vous pouvez télécharger PhantomJS 2.5 beta à partir de cette page .

Voir également:
CasperJS / PhantomJS ne charge pas la page https
PhantomJS n'arrive pas à ouvrir le site HTTPS Vous devez ajouter les rappels suivants pour saisir toutes les erreurs:

 casper .on("error", function(msg){ this.echo("error: " + msg, "ERROR") }) .on("page.error", function(msg, trace){ this.echo("Page Error: " + msg, "ERROR") }) .on("remote.message", function(msg){ this.echo("Info: " + msg, "INFO") });