问题
I'm trying to load this page: https://login.morganstanleyclientserv.com/
My current code:
var casper = require('casper').create();
var x = require('casper').selectXPath;
var userName = 'xxxxxx';
var Password = 'xxxxxx';
casper.userAgent('Mozilla/4.0 (comptible; MSIE 6.0; Windows NT5.1)');
casper.start('https://login.morganstanleyclientserv.com/')
casper.then(function () {
this.sendKeys('#txtUsername', userName);
console.log('Entering Username');
});
casper.then(function() {
this.sendKeys('#txtPassword', Password);
console.log('Entering Password');
});
casper.thenClick(x('//*[@id="btnLogin"]'), function() {
console.log('Logging in');
casper.wait(5000, function() {
casper.capture('myImage.png')
});
});
casper.run();
I use this code for multiple reports that I pull daily on different sites (all are https) and have no problems. The capture is returning just a black image and the script is timing out and not finding either selector for username and password. I've tried the "waitForSelector()" with no success so I'm assuming the DOM is not loading in like I think it is? I'm using phantom v2.1.1 and Casper v1.1.4
来源:https://stackoverflow.com/questions/47874294/script-is-timing-out-and-not-finding-selector