Script is timing out and not finding selector

旧街凉风 提交于 2019-12-11 05:08:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!