CasperJS : Why does my url change to about:blank when my page is loaded?

后端 未结 2 1201
庸人自扰
庸人自扰 2021-02-05 22:12

I\'m a beginner at PhantomJS/CasperJS.

I just want to start a session and verify that it\'s OK.

Here\'s my code:

var casper = require(\'casper\').cr         


        
2条回答
  •  走了就别回头了
    2021-02-05 22:20

    I also had this same enigmatic debug logging for my step:

    [debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true
    [debug] [phantom] url changed to "about:blank"
    

    In my case I needed to click Submit button on an AJAX form that was a link element with href='javascript:;'. It turned out this in itself was not the main problem. Rather it was that their web system was built with Apache Wicket java web framework, which issues stateful sessions for each search interaction. And it happens via redirection – and this was the key point here.

    Now CasperJS supports two engines PhantomJS and SlimerJS... When digging into CasperJS documentation I wound this linked page Differences between SlimerJS and PhantomJS which states:

    'PhantomJS doesn’t do redirections, whereas SlimerJS does.'

    For reference here was my options as set to be most loose and with debug enabled (some of these are with the default values):

    var casper = require('casper').create({
        engine: 'slimmerjs',
        verbose: true,
        logLevel: 'debug',
        exitOnError: false,
        ignoreSslErrors: true,
        pageSettings: {
            javascriptEnabled: true,
            loadImages: true,
            loadPlugins: true,
            localToRemoteUrlAccessEnabled: true,
            userAgent: 'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36',
            XSSAuditingEnabled: false,
            logLevel: 'debug'
        }
    });
    

提交回复
热议问题