2016-12-01 1 views

답변

1

그것은 두 가지 방법으로 가능이 작동합니다 : 당신은 sendKeys() 대신 fillSelectors()을 사용할 수 있습니다

var casper = require('casper').create({ 
    verbose: true, 
    logLevel: 'debug', 
    waitTimeout: 5000, 
    userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0', 
    viewportSize:{width: 1600, height: 900} 
}); 
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") }); 

casper 
    .start("https://www.wikifolio.com/de/de/home", function(){ 
    this.click('div.js-change-country-mode-btn'); 
    this.wait(500,function(){this.click('a.js-login-button')}); 
    this.wait(500,function(){ 
    this.fillSelectors('form[action$=login]', { 
     "input#Username" : "[email protected]", 
     "input#Password" : "<pass>" 
    },true); 
}) 
}) 
    .then(function(){ 
    this 
.capture("Afterlogin.png") 
.wait(5000,function(){ this.capture("Afterlogin2.png") }) 
    }) 
     .run(); 

.
파일 : Afterlogin.png
파일 : Afterlogin2.png

이 너무 작동합니다
당신은 쿠키 사용하여 작업을 수행 할 수 있습니다 : 두 번째 솔루션에서

var casper = require('casper').create({ 
    verbose: true, 
    logLevel: 'debug', 
    waitTimeout: 5000, 
    userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0', 
    viewportSize:{width: 1600, height: 900} 
}); 
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") }); 

//for www.wikifolio.com/de/de/home auth 
phantom.cookies = [{// an array of objects 
    'name'  : 'theAuthCookie', 
    'value' : '<very long string>', 
    'domain' : 'www.wikifolio.com', 
    'path'  : '/', 
    'httponly' : false, 
    'secure' : true, 
    'expires' : (new Date()).getTime() + (1000 * 60 * 60 * 43800) //5 years 
},{ 'name'  : 'DisclaimerCountryPopupV2', 
    'value' : 'de', 
    'domain' : 'www.wikifolio.com', 
    'path'  : '/', 
    'httponly' : false, 
    'secure' : true, 
    'expires' : (new Date()).getTime() + (1000 * 60 * 60 * 43800) }] 

var target = "https://www.wikifolio.com/de/de/alle-wikifolios/suche#/?tags=aktde,akteur,aktusa,akthot,aktint,etf,fonds,anlagezert,hebel&media=true&private=true&assetmanager=true&theme=true&super=true&WithoutLeverageProductsOnly=true&languageOnly=true" 

casper 
    .start(target, function(){ }) 
    .then(function(){ 
    this 
.capture("Afterlogin.png") 
.wait(5000,function(){ this.capture("Afterlogin2.png") }) 
    }) 
     .run(); 
+2

을, 로그인은? 또는 로그인을 추가해야합니까? –

+2

로그인 정보가'theAuthCookie' 값에 저장되어 있다고 생각하십니까? –

관련 문제