我想使用facebook分享对话框
与casperjs 我设法从第一个下拉列表中选择了帖子模式“组”,但是当我厌倦了填写组名输入时我失败了(我认为它使用了ajax下拉列表)
没有运气,这是我的代码。
var casper = require('casper').create({
pageSettings: {
loadImages: false,
loadPlugins: true,
userAgent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0'
},
logLevel: "info",
verbose: true
});
casper.options.stepTimeout = 60000;
var fs = require('fs');
var x = require('casper').selectXPath;
var x1 = require('casper').selectXPath;
casper.start('http://facebook.com/login.php', function() {
console.log("page loaded");
this.test.assertExists('form#login_form', 'form is found');
this.fill('form#login_form', {
email: 'email',
pass: 'pass'
}, true);
this.wait(1000, function() {
casper.capture('login.png');
console.log("screen captured");
});
});
casper.thenOpen('https://www.facebook.com/dialog/share?app_id=966242223397117&redirect_uri=http://www.facebook.com/dialog/return/close&display=popup&href=http://www.isearchforjob.com/', function() {
console.log("debug loaded");
this.wait(1000, function() {
casper.capture('debug.png');
console.log("screen captured");
});
if (this.exists('span._55pe')) {
this.click('span._55pe');
casper.then(function() {
this.click(x('//span[text()="Share in a group"]'))
});
casper.waitForSelector('input#audience_group', function(){
casper.capture('clicked0.png');
this.fillSelectors('form#platformDialogForm', {
'input#audience_group': 'test'
}, false);
casper.capture('clicked01.png');
});
}
});
casper.run();
我也试过
this.sendKeys('#audience_group','group name');