2017-12-12 5 views
1

PhantonJS를 사용하여 protonmail에 입장하려고합니다. 로그인과 비밀번호를 입력하고 로그인 버튼을 누릅니다. 누르지 마십시오. 나는 누르려고 노력했다. 그래서.PhantomJS를 사용하여 Protonmail에 로그인하지 마십시오.

page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
    var lbx1x1x1a = document.getElementById("login_btn"); 
    var lbx1x1x1e = document.createEvent("MouseEvents"); 
    lbx1x1x1e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
    lbx1x1x1a.dispatchEvent(lbx1x1x1e); 
},ps,p); 

작동하지 않습니다, 아무 일도 발생하지

그래서 : 작동하지 않습니다

var point = page.evaluate(function() { 
    var element = document.getElementById('login_btn'); 
    var rect = element.getBoundingClientRect(); 
     return { 
       x: rect.left + Math.floor(rect.width/2), 
       y: rect.top + Math.floor(rect.height/2) 
     }; 
}); 
point.x=Math.floor(point.x); 
point.y=Math.floor(point.y); 
console.log(point.x+" "+point.y); 
page.sendEvent('click', point.x, point.y); 

는, 아무것도

page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
    document.getElementById("pm_login").submit(); 

},ps,p); 

이 작동하지 않는 일이 없지만, 로그의 필드와 암호가 지워집니다.

작동하지 않습니다
page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").focus(); 
},ps,p); 

page.sendEvent('keypress', "123\r"); 
page.sendEvent('keypress', page.event.key.A, null, null, 0x02000000 | 0x08000000); 

는, 아무것도 작동하지 않습니다

page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
    document.getElementById("login_btn").focus(); 
},ps,p); 

page.sendEvent('keypress', "\r"); 
page.sendEvent('keypress', page.event.key.A, null, null, 0x02000000 | 0x08000000); 

을 발생하지 아무 일도 발생하지 않습니다. 더 이상 아이디어가 없습니까? 감사합니다.

Phantomjs 2.1.1

안녕하세요! Vaviloff에 감사드립니다.) 오류 코드가 발견되면 해당 코드를 붙여 넣습니다.

page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
    document.getElementById("login_btn").click(); 
    var lbx1x1x1a = document.getElementById("login_btn"); 
    var lbx1x1x1e = document.createEvent("MouseEvents"); 
    lbx1x1x1e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
    lbx1x1x1a.dispatchEvent(lbx1x1x1e); 
},ps,p); 

    page.onResourceError = function(resourceError) { 
     console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')'); 
     console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString); 
    }; 

    page.onConsoleMessage = function(msg, lineNum, sourceId) { 
     console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")'); 
    }; 

    page.onError = function(msg, trace) { 
     var msgStack = ['ERROR: ' + msg]; 
     if (trace && trace.length) { 
      msgStack.push('TRACE:'); 
      trace.forEach(function(t) { 
       msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : '')); 
      }); 
     } 
     console.error(msgStack.join('\n')); 
    }; 

오류 없음. phantomjs를 실행하면 콘솔에 다음 메시지가 표시되지만 로그인을 시도하기 전에 발생합니다.

같은 페이지에서 동시에 다른 요소를 클릭 할 수 있으며 작동합니다. 다음 코드는 정상적으로 작동합니다.

page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
    var lbx1x1x1a =document.getElementsByClassName ("loginForm-btn-help")[0]; 
    var lbx1x1x1e = document.createEvent("MouseEvents"); 
    lbx1x1x1e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
    lbx1x1x1a.dispatchEvent(lbx1x1x1e); 

},ps,p); 

또는

page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
    var lbx1x1x1a =document.getElementsByClassName ("loginForm-actions-main pm_button primary pull-right loginForm-btn-submit")[0]; 
    var lbx1x1x1e = document.createEvent("MouseEvents"); 
    lbx1x1x1e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
    lbx1x1x1a.dispatchEvent(lbx1x1x1e); 
},ps,p); 

ScreenShot - signup

다른 요소는 더 로그인을 클릭 할 수 없습니다. 나는 그것을 누를 수 없다. catch는 어디에 있습니까? 감사합니다. .

그래서 중 하나가 작동하지 않습니다

page.includeJs('https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'); 
    setTimeout(InterLoginData, 90000); 


function InterLoginData(){ 
console.log ("Phantomjs.InterLoginData and Login."); 
page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
    //document.getElementById("password").focus(); 

    document.getElementById("login_btn").click(); 
    document.getElementById("login_btn").submit(); 

    $("login_btn").click(); 
    $("#login_btn").click(); 

    $("login_btn").submit(); 
    $("#login_btn").submit(); 


},ps,p); 

프롬 구글 크롬 콘솔을 그 :

document.getElementById("login_btn").click(); 

그 코드 : 제대로

var lbx1x1x1a = document.getElementById("login_btn"); 
var lbx1x1x1e = document.createEvent("MouseEvents"); 
lbx1x1x1e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
lbx1x1x1a.dispatchEvent(lbx1x1x1e); 

작품. 제발 아이디어를 던져주세요. 감사.

+0

page.onError 콜백으로 오류를 확인하십시오. 거기에 어떤 오류가 있습니까? – Vaviloff

+0

안녕하세요! 바빌로프 감사) – Pigrowant

답변

0

밝혀 졌을 때 버튼을 눌렀습니다. 그러나. 그것은 그 코드 뒤에 밝혀졌다 :

page.evaluate(function(ps,p){ 
    var eps=ps; 
    var ep=p; 
    document.getElementById("username").value = eps; 
    document.getElementById("password").value = ep; 
},ps,p); 

로그인 및 암호 필드가 작성되지 것을 고려 페이지. 그리고 그 페이지는 들판을 채우라는 메시지를 보냈습니다. 짧은 시간 동안 등장했기 때문에 스크린 샷에서 사이트를 보지 못했고 화면 캡처 당시에는 이미 사라졌습니다. SlimerJS에서 코드를 실행하여 이것을 볼 수있었습니다 (감사합니다). 다음 코드는 정상적으로 작동합니다. 입력 할 버튼을 누르고 메일에 들어갔습니다.) 감사합니다.

//************* 
var ps="PUT_LOGIN_HERE" 
var p="PUT_PASSWORD_HERE" 
//************* 

page.evaluate(function(){ 
    document.getElementById("username").focus(); 
}); 
page.sendEvent('keypress', ps); 


page.evaluate(function(){ 
    document.getElementById("password").focus(); 
}); 
page.sendEvent('keypress', p); 
page.sendEvent('keypress', "\n");//Enter