johntitus / node-horseman

Run PhantomJS from Node
MIT License
1.45k stars 124 forks source link

login in app using facebook #279

Open shekhartyagi26 opened 7 years ago

shekhartyagi26 commented 7 years ago

i am accessing in login page using horseman but unable to get the website image after login var horseman = new Horseman({ phantomPath: phantomjs.path});

// login in zarpo using facebook
horseman 
    .userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
    .open('https://m.zarpo.com.br/customer/account/login/')
    .click('[class="fb_button"]')
    .waitForNextPage()
    .switchToTab(1)    
    .type('input[name="email"]', 'email')
    .type('input[name="pass"]', 'password')
    .click('[name="login"]')
    .screenshot('abc.png')
    .switchToTab(0) 
    .url()
    .then(function(url){
        console.log(url)
    })
    .reload()
    // .wait(5000)
    .screenshot('abc1.png')
    .close();

when redirecting the url on previous page here in abc1.png i got the same image as i click at first time

awlayton commented 7 years ago

Please run with BLUEBIRID_DEBUG=1 and DEBUG='horseman*' set, then post the output log (you can redact your username and password first) and the screenshots generated.

shekhartyagi26 commented 7 years ago

here this is the output what i got from DEBUG='horseman*' BLUEBIRD_DEBUG=1 node index.js

horseman using PhantomJS from phantomjs-prebuilt module +0ms horseman .setup() creating phantom instance 1 +216ms horseman phantom created +187ms horseman phantom version 2.1.1 +16ms horseman page created +9ms horseman phantomjs onLoadFinished triggered +9ms success NaN horseman injected jQuery +17ms horseman .userAgent() set +12ms Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0 horseman .open() +1ms https://m.zarpo.com.br/customer/account/login/ horseman phantomjs onLoadFinished triggered +8s success 1 horseman jQuery not injected - already exists on page +4ms horseman .click() +4ms [class="fb_button"] horseman page created +37ms horseman .click() done +2ms horseman .waitForNextPage() +0ms horseman:verbose onConsoleMessage +3s

.d8888b. 888 888
d88P Y88b 888 888
Y88b. 888 888 Este é um recurso de navegador voltado "Y888b. 888888 .d88b. 88888b. 888 para desenvolvedores. Se alguém disse "Y88b. 888 d88""88b 888 "88b 888 para você copiar e colar algo aqui para "888 888 888 888 888 888 Y8P ativar um recurso do Facebook ou "invadir" Y88b d88P Y88b. Y88..88P 888 d88P a conta de outra pessoa, isso é uma fraude "Y8888P" "Y888 "Y88P" 88888P" 888 e você dará a ele acesso à sua conta. 888
888
888

Consulte https://www.facebook.com/selfxss para obter mais informações. line: undefined in undefined 1 horseman phantomjs onLoadFinished triggered +1ms success 2 horseman injected jQuery +12ms horseman .waitForNextPage() completed successfully +55ms horseman .type() +1ms input[name="email"] etechmusic8@gmail.com undefined horseman .keyboardEvent() +16ms keypress e null horseman .keyboardEvent() +4ms keypress t null horseman .keyboardEvent() +3ms keypress e null horseman .keyboardEvent() +5ms keypress c null horseman .keyboardEvent() +8ms keypress h null horseman .keyboardEvent() +4ms keypress m null horseman .keyboardEvent() +3ms keypress u null horseman .keyboardEvent() +4ms keypress s null horseman .keyboardEvent() +4ms keypress i null horseman .keyboardEvent() +6ms keypress c null horseman .keyboardEvent() +7ms keypress 8 null horseman .keyboardEvent() +3ms keypress @ null horseman .keyboardEvent() +4ms keypress g null horseman .keyboardEvent() +5ms keypress m null horseman .keyboardEvent() +4ms keypress a null horseman .keyboardEvent() +3ms keypress i null horseman .keyboardEvent() +4ms keypress l null horseman .keyboardEvent() +6ms keypress . null horseman .keyboardEvent() +5ms keypress c null horseman .keyboardEvent() +5ms keypress o null horseman .keyboardEvent() +3ms keypress m null horseman .type() +1ms input[name="pass"] password undefined horseman .keyboardEvent() +22ms keypress p null horseman .keyboardEvent() +5ms keypress a null horseman .keyboardEvent() +4ms keypress s null horseman .keyboardEvent() +4ms keypress s null horseman .keyboardEvent() +3ms keypress w null horseman .keyboardEvent() +3ms keypress o null horseman .keyboardEvent() +5ms keypress r null horseman .keyboardEvent() +5ms keypress d null horseman .click() +0ms [name="login"] horseman .click() done +20ms horseman .screenshot() +1ms abc.png horseman .url() +32ms https://m.zarpo.com.br/customer/account/login/ horseman .reload() +6ms horseman .screenshot() +6ms abc1.png horseman .close(). +98ms

this is image what i found at the end i.e abc1.png abc1

awlayton commented 7 years ago

Nothing is actually being typed into either the email or password boxes.

I think your selectors could be wrong. When I visited the site, the name of the email box was "step1[email]", not "email". If I were you, I would double-check all the CSS selectors being used.

shekhartyagi26 commented 7 years ago

I think you are not understanding what i have to do, there is no need of step1[email] , actually i have to login in app using Facebook so these are steps which i have to follow:

1) click on Facebook button first(.click('[class="fb_button"]'))
2) then a new tab open i.e facebook tab
3) write the emailid their and password(.type('input[name="email"]', 'email')
.type('input[name="pass"]', 'password'))
4) click on the login button(.click('[name="login"]'))
5) then this page loads and redirect to tab 1, i want that when i
return to app page, then at that time, login in app is done.i.e screenshot after login
awlayton commented 7 years ago

What does the screenshot of the other tab look like?

Also, it seems an error gets printed to the console after the first .waitForNextPage(), but it is not in English so I do not know what it is about.

shekhartyagi26 commented 7 years ago

the screenshot of other tab looks like this abc but i think there is no issue for .waitForNextPage(), can you please help me out how i login with facebok in my app. i don't know where i am doing wrong .

awlayton commented 7 years ago

Judging by the screenshot, it doesn't look like your email was actually typed in.

shekhartyagi26 commented 7 years ago

i write "username" only for demo, otherwise its having the email whatever i type

awlayton commented 7 years ago

Try putting a .wait(500) or something between .click('[name="login"]') and .screenshot('abc.png') to give the page time to respond to the click.

shekhartyagi26 commented 7 years ago

i already try that but it's not working . if i use .wait(500) then i got the same image in output .or if i use .wait(5000) then error comes

Unhandled rejection Error: jQuery injection failed at /usr/lib/node_modules/node-horseman/lib/index.js:307:18 at PassThroughHandlerContext.finallyHandler (/usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/finally.js:56:23) at PassThroughHandlerContext.tryCatcher (/usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/promise.js:510:31) at Promise._settlePromise (/usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/promise.js:567:18) at Promise._settlePromise0 (/usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/promise.js:612:10) at Promise._settlePromises (/usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/promise.js:691:18) at Promise._fulfill (/usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/promise.js:636:18) at /usr/lib/node_modules/node-horseman/node_modules/bluebird/js/release/nodeback.js:42:21 at /usr/lib/node_modules/node-horseman/node_modules/node-phantom-simple/node-phantom-simple.js:60:18 at IncomingMessage. (/usr/lib/node_modules/node-horseman/node_modules/node-phantom-simple/node-phantom-simple.js:645:9) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) this is because when we click on the facebook page to login then it's redirects to tab 1 and close automatically.