Skip to content

Instantly share code, notes, and snippets.

@fabsrc
Last active May 11, 2016 17:44
Show Gist options
  • Save fabsrc/336674578f46216c1890 to your computer and use it in GitHub Desktop.
Save fabsrc/336674578f46216c1890 to your computer and use it in GitHub Desktop.
Change Facebook Profile Picture with Nightmare.js
var Nightmare = require('nightmare');
function changeFacebookProfilePicture(email, pass, id) {
new Nightmare({
show: false,
'webPreferences':{
partition: 'nopersist'
}
}).goto('https://facebook.com')
// .screenshot(__dirname + '/00.png')
.type('input#email', email)
.type('input#pass', pass)
// .screenshot(__dirname + '/01.png')
.click('#loginbutton input')
// .screenshot(__dirname + '/02.png')
.wait(3000)
// .screenshot(__dirname + '/03.png')
.goto('https://www.facebook.com/photo.php?fbid=' + id)
// .screenshot(__dirname + '/04.png')
.wait('.profilePicButton')
// .screenshot(__dirname + '/05.png')
.click('.profilePicButton')
// .screenshot(__dirname + '/06.png')
.wait('button._4jy0._4jy3._4jy1._51sy.selected._42ft')
// .screenshot(__dirname + '/07.png')
.click('button._4jy0._4jy3._4jy1._51sy.selected._42ft')
// .screenshot(__dirname + '/08.png')
.wait(3000)
.click('#pageLoginAnchor')
// .screenshot(__dirname + '/09.png')
.wait('a[data-gt=\'{"ref":"async_menu","logout_menu_click":"menu_logout"}\']')
// .screenshot(__dirname + '/10.png')
.click('a[data-gt=\'{"ref":"async_menu","logout_menu_click":"menu_logout"}\']')
// .screenshot(__dirname + '/11.png')
.wait(3000)
// .screenshot(__dirname + '/12.png')
.run(function (err) {
if (err) return console.log(err);
console.log('Done!');
process.exit(0);
});
};
@nick2012
Copy link

Hi,

This line doesn't seem to work for me:
.click('#loginbutton input')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment