Javascript CasperJS登录Ghost CMS并截图
这是我目前的剧本 我还为你们发布了代码下面的内容 当它运行时,它不会停止,也不会返回屏幕截图,只是挂起,没有错误或任何东西Javascript CasperJS登录Ghost CMS并截图,javascript,casperjs,Javascript,Casperjs,这是我目前的剧本 我还为你们发布了代码下面的内容 当它运行时,它不会停止,也不会返回屏幕截图,只是挂起,没有错误或任何东西 var casper = require('casper').create({ verbose: true, logLevel: 'debug', pageSettings: { loadImages: true, loadPlugins: true, userAgent: 'Mozilla/5.0 (Windows NT 10.0; W
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings: {
loadImages: true,
loadPlugins: true,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0'
}
});
casper.start('https://dilionsmith.me/ghost/#/signin', function() {
this.waitForSelector('form[method="post"]');
});
casper.then(function() {
console.log("page loaded");
this.fill('form[method="post"]', {
identification: 'email',
password: 'pass'
}, true);
});
casper.then(function() {
casper.capture('after.png');
});
casper.run();
输出:
[info] [phantom] Starting...
[info] [phantom] Running suite: 4 steps
[debug] [phantom] opening url: https://dilionsmith.me/ghost/#/signin, HTTP GET
[debug] [phantom] Navigation requested: url=https://dilionsmith.me/ghost/#/signin, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://dilionsmith.me/ghost/#/signin"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/4 https://dilionsmith.me/ghost/#/signin (HTTP 200)
[info] [phantom] Step anonymous 2/4: done in 578ms.
[info] [phantom] Step _step 3/5 https://dilionsmith.me/ghost/#/signin (HTTP 200)
[info] [phantom] Step _step 3/5: done in 598ms.
[debug] [phantom] Navigation requested: url=https://dilionsmith.me/ghost/#/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://dilionsmith.me/ghost/#/"
[debug] [phantom] url changed to "https://dilionsmith.me/ghost/#/"
问题是您没有在“”上包含输入名称: 应该是:
casper.then(function() {
console.log("page loaded");
this.fill('form[method="post"]', {
'identification': 'email',
'password': 'pass'
}, true);
});
希望有帮助。步骤2/4和3/5?这是完整的日志吗?填写表格的日志在哪里?如果有敏感信息,不要删除,用****替换。这是完整的日志,我想现在我才发现真正的问题是表单没有提交或填写。
casper.then(function() {
console.log("page loaded");
this.fill('form[method="post"]', {
'identification': 'email',
'password': 'pass'
}, true);
});