Casperjs fill input without name

时间秒杀一切 提交于 2020-01-14 04:33:05

问题


i want to use facebook share dialog

Link to share dialog

with casperjs i managed to select the post mode "group" from the first dropdown , but i failed when i tired to fill the group name input (i think it use ajax drop down list)

Screenshot of result

with no luck , here is my code .

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();

i tried also

this.sendKeys('#audience_group','group name');

来源:https://stackoverflow.com/questions/36045035/casperjs-fill-input-without-name

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