Last active
May 11, 2016 17:44
-
-
Save fabsrc/336674578f46216c1890 to your computer and use it in GitHub Desktop.
Change Facebook Profile Picture with Nightmare.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
This line doesn't seem to work for me:
.click('#loginbutton input')