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

后端 未结 2 1254
庸人自扰
庸人自扰 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:29

    There are open issues (see update below) on CasperJS and PhantomJS Github Repos regarding redirecting to/opening about:blank page

    • Issue 13738 Phantomjs opens a about:blank page instead of the URL

    • Issue 1485 Redirect to url=about:blank

      Updated on March 09 2017: Issue 1485 solved. See @jefleponot comment on GitHub for the solution

      Haven't confirmed it myself, but @Ross commented that adding the option --ssl-protocol=any for phantomjs solved the issue


    • --proxy-type=none command-line argument

    On Windows, the default proxy setting may cause a massive network latency (see Known Issues in the release note). The workaround is to disable proxy completely, e.g. by launching PhantomJS with --proxy-type=none command-line argument. 1


    Your code worked correctly, with the following versions :

    • PhantomJS 2.1.1
    • CasperJS 1.0.4
    • MacOSX

    [info] [phantom] Starting...
    [info] [phantom] Running suite: 3 steps
    [debug] [phantom] opening url: https://www.google.fr/, HTTP GET
    [debug] [phantom] Navigation requested: url=https://www.google.fr/, type=Other, lock=true, isMainFrame=true
    [debug] [phantom] url changed to "https://www.google.fr/"
    [debug] [phantom] Successfully injected Casper client-side utilities
    [debug] [phantom] start page is loaded
    [info] [phantom] Step 3/3 https://www.google.fr/ (HTTP 200)
    Page Loaded
    PASS Welcome to Google
    [info] [phantom] Step 3/3: done in 262ms.
    [info] [phantom] Done 3 steps in 341ms
    

    There were some issues with page navigation in casperjs 1.1.x beta and PhantomJS >1.9.8 where the recommendation was to downgrade PhantomJS to 1.9.7


    I would recommend, if possible, to try different versions

    Either Github Issue 1485 solution or @Ross solution may solve the problem - any comments?

提交回复
热议问题