JQuery Not"点击"使用PhantomJS进行选择

时间:2017-03-20 16:52:44

标签: javascript jquery phantomjs

我正在努力教自己如何更好地使用PhantomJS。

我想要点击一个特定的选择器(如下所示)。

#s-t-menu > li:nth-child(3) > a

我已打开一个页面,已登录,现在想要关注链接。但是,到目前为止,我在跟踪此链接方面一直没有结果(登录成功)。我的代码如下:

//********SETUP**********\\
var webPage = require('webpage');
var page = webPage.create();


page.settings.userAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36';
page.settings.javascriptEnabled = true;
page.settings.loadImages = false;
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;

page.onConsoleMessage = function(msg, lineNum, sourceId) {
    console.log(msg);
};
//******END SETUP************\\

//******FUNCTIONS************\\

                  function click(el){
    var ev = document.createEvent("MouseEvent");
    ev.initMouseEvent(
        "click",
        true /* bubble */, true /* cancelable */,
        window, null,
        0, 0, 0, 0, /* coordinates */
        false, false, false, false, /* modifier keys */
        0 /*left*/, null
    );
    el.dispatchEvent(ev);
}

//******END FUNCTIONS*******\\


//*****OPEN PAGES*****\\
page.open("https://helphub.me/login", function(status) {

    if ( status === "success" ) {
        console.log("Opened Login Page Succesfully \n");

        page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function(){
        page.evaluate(function() {

              //*****LOGS IN*****\\
              document.querySelector("#login_header > span.ll > form > input:nth-child(1)").value = "REDACTED_FOR_STACKEXCHANGE";
              document.querySelector("#login_header > span.ll > form > input:nth-child(2)").value = "REDACTED_FOR_STACKEXCHANGE";
              document.querySelector("[name='loginf']").submit();
              console.log("Logged In \n");


              document.querySelector("#s-t-menu > li:nth-child(3) > a").click();



        });
        });

                    //*****SCREENSHOT FOR EVALUATION*****\\

                    window.setTimeout(function () {
          page.render('/Screenshots/LoggedIn.png');
          phantom.exit();
        }, 5000);
           //******SCREENSHOT END****************\\


   }
});
//*****END OPEN PAGES*****\\

在当前状态下,我在控制台中收到以下内容:

Opened Login Page Succesfully 

The page at https://helphub.me/login ran insecure content from http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js.

Facebook Pixel Warning: Multiple pixels with conflicting versions were detected on this page
Logged In 

TypeError: null is not an object (evaluating 'document.querySelector("#s-t-menu > li:nth-child(3) > a").click')

  undefined:10
  :14
Facebook Pixel Warning: Multiple pixels with conflicting versions were detected on this page

我也尝试过:

$("#s-t-menu > li:nth-child(3) > a").click();

并获取

Opened Login Page Succesfully 

The page at https://helphub.me/login ran insecure content from http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js.

Logged In 

Facebook Pixel Warning: Multiple pixels with conflicting versions were detected on this page

在所有这些情况下,当我去查看截图时,我现在处于正确的屏幕上;我刚刚登录。

当我运行命令时,我包括

 --ignore-ssl-errors=yes

最后,我尝试使用Google Chrome控制台

document.querySelector("#s-t-menu > li:nth-child(3) > a").click();

在登录页面上,它工作正常。

任何帮助表示赞赏! :)

整个HTML网页来源如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
    <meta charset="utf-8" />
    <meta property="og:type" content="website" />
<meta property="og:title" content="" />
<meta property="og:url" content="https://helphub.me/dashboard/?signup=success" />
<meta property="og:description" content="" />

            <meta name="description" content="Get help from expert online tutors over online messaging and tutoring calls, 24/7. Get started with online tutoring today!" />
    <meta property="og:description" content="HelpHub connects students with tutors over online messaging and tutoring calls." />
    <link rel="image_src" href="https://helphub.me/img/ogimage.jpg" />
<meta property="og:image" content="https://helphub.me/img/ogimage.jpg" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Dashboard – HelpHub" />
<meta property="og:url" content="https://helphub.me/" />
        <title>Dashboard – HelpHub</title>
    <base href="https://helphub.me/" />
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
<meta name="apple-itunes-app" content="app-id=915930220">
<link href="https://helphub.me/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
<link href="https://helphub.me/animations.css" media="screen" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="jquery.timepicker.css" />
<link rel="stylesheet" type="text/css" href="https://helphub.me/d_base.css" />
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.css" />
<link type="text/css" rel="stylesheet" media="all" href="chat/css/chat.css" />
<script type="text/javascript" src="https://helphub.me/javascript/jquery-1.10.2.min.js"></script>
<script src='https://static.opentok.com/v2/js/opentok.min.js'></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="/inputfocus.js"></script>
<script type="text/javascript" src="/functions.js"></script>

<script type="text/javascript" src="chat/js/chatjs.php"></script>

<!--[if lte IE 7]>
<link type="text/css" rel="stylesheet" media="all" href="css/screen_ie.css" />
<![endif]-->

<script type="text/javascript" src="//use.typekit.net/pyo7dcc.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>

<script src="javascript/call_tutor.js"></script>
<script type="text/javascript" src="javascript/accept_call.js"></script>
<link rel="stylesheet" type="text/css" href="css/whiteboard.css" />
<link rel="stylesheet" href="/jquery.fancybox.css?v=2.1.4" type="text/css" media="screen" />
<link href="flat.css" rel="stylesheet" />
<link rel="stylesheet" href="css/basics.css">
<link rel="stylesheet" href="css/font-awesome.min.css">

<script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="js/tutor_dashboard.js"></script>
<link href="/css/tutor_dashboard.css" media="screen" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/jquery.datetimepicker.css"/ >
    <script type="text/javascript">(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==
typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");for(g=0;g<i.length;g++)f(c,i[g]);
b._i.push([a,e,d])};b.__SV=1.2}})(document,window.mixpanel||[]);
mixpanel.init("96c84aa9e26ab91ee361872c1c01a430");</script>
</head>
<body>
<script type="text/javascript">
var WRInitTime=(new Date()).getTime();
</script>


    <div id="header">
        <ul id="call-notification"></ul>
        <div class="container">
            <div class="top">
                <h4 class="logo"><a href="./dashboard" class="indent">HelpHub</a></h4>





                                <span class="searchheader">

                    <form method="get" action="/search/" name="searchheader">
                        <div class='bbox'>
                            <input class="searchh" name="q" value="Search tutors by subject, school, or city..." id="search" />
                        </div>
                    </form>

                </span>


                <span class="usettings">
                    <i class="settings"><a href="/settings"></a></i>
                    <ul class="settings_pulldown settings_pulldown_s">
                        <li><h4>Your credits are: <br><span id="show_my_user_balance">$0.00</span><span id="my_user_balance">0</span></h4><br><a href="/settings/billing" class="btn btn-success vam">Add Credits</a></li>
                        <li><a href="/settings">Profile Settings</a></li>
                        <li><a href="/settings/billing">Add Credits</a></li>
                                                <li><a href="/settings/tutoring">Tutoring Settings</a></li> 
                                                <li><a href="/logout.php">Logout</a></li>
                    </ul>

                                        <a class="msgs_h" href="/dashboard"><i class="glyphicon glyphicon-dashboard"></i></a>



                    <a class="msgs_h" href="/messages"><i class="glyphicon glyphicon-envelope"></i></a>

                    <i class="ask tooltipthis" data-tooltip="Post a question and reach all of our tutors at once. You will be notified when you receive answers."><a data-toggle="modal" data-target="#AskModal" href="#"></a></i>
                    <a href="/TestGroundTutoring" class="myavatar"><img class="avatar_tip" alt="" src="img/noavatar.jpg" /></a>
                </span> 






                            </div>
        </div>
    </div>



<div class="main_dashboard_container">
    <div id="dashboard_sidebar">
        <div class="sidebar_content_dashboard">
            <div class="sidebar_uinfo">
                <div class="s-u-photo">
                    <a href="/TestGroundTutoring"><img alt="" src="img/noavatar.jpg" /></a>
                </div>
                <span class="s-u-balance">
                    Your earnings: <strong>$0.00</strong>
                </span>
            </div>  
            <ul id="s-t-menu">
                <li><a href="/dashboard"><i class="fa fa-tachometer"></i> Dashboard</a></li>
                <li><a href="/messages"><i class="fa fa-envelope"></i>Messages</a></li>
                <li><a href="/questions"><i class="fa fa-question-circle"></i>Questions</a></li>


                <li><a href="/calendar"><i class="fa fa-calendar"></i>Calendar</a></li>
                <li><a href="/dashboard/group-tutoring"><i class="fa fa-users"></i>Group Tutoring</a></li>
                <li>
                    <a href="/settings"><i class="fa fa-cog"></i>Settings</a>
                    <ul class="n_menu">
                        <li><a href="/settings"><i class="fa fa-user"></i>Profile Settings</a></li>
                        <li><a href="/settings/tutoring"><i class="fa fa-cogs"></i>Tutoring Settings</a></li>
                        <li><a href="/settings/availability"><i class="fa fa-clock-o"></i>Set Availability</a></li>
                        <li><a href="/settings/payments"><i class="fa fa-money"></i>Payment Settings</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div id="middle-container-d">
        <div class="container_dashboard">


        <div class="dashboard_widget">
                <h2>Twitter Leads</h2>

                <p class="tw_leads_link">If you'd like to share your HelpHub profile with people on Twitter, simply tweet this link:
                    https://helphub.me/TestGroundTutoring</p>

                <div class="dash_scrollable twitter_leads">
                <p>Twitter leads are temporarily unavailable. Please check back later.</p>
                </div>

            </div>



            <div class="dashboard_widget">
                <h2>Your profile visibility</h2>
                <div class="dash_scrollable">
                    <div class="tutor_iq_section">
                        <h4>Your <em>Tutor Karma</em> is</h3>
                        <h3>
                            100                     </h3>
                        <p>Your <em>Tutor Karma</em> increases your visibility on the site. These are some ways you can increase it:</p>
                    </div>

                    <div id="show_dashboard_tips"></div>

                    <script type="text/javascript">

                        $(document).ready(function(){
                            get_dashboard_tips();
                        });

                    </script>


                </div>
            </div>

            <div class="dashboard_widget">
                <h2>Who's seen your profile</h2>
                <div class="dash_scrollable">
                    <p>Nobody has recently seen your profile.</p>               </div>
            </div>

            <div class="dashboard_widget">
                <h2>Your account activity</h2>
                <div class="dash_scrollable">
                    <p>Your account hasn't had any recent tutoring activity.</p><p>Every time you call a tutor, you will see the amount spent and the length of the call.</p>               </div>
            </div>


        </div>
    </div>





</div>
<!-- end of lp container -->

<div id="AskModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  <div class="modal-header">
    <h2 id="myModalLabel">Ask a Question</h2>
  </div>
   <p class="qa_alert">Looking for the <strong><a href="/tutors-forum">Tutors Forum</a></strong>? Please <strong><a href="/tutors-forum">go to the Tutors Forum</a></strong> to post new questions. You can also access the forum from the bottom of the page.</p>
  </div>
<script type="text/javascript">
var CE_SNAPSHOT_NAME = "Dashboard";
</script>



<div id="SignUpModal" class="modal hide fade signupmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false"><div class="modal-header">You need to create an account to continue</div>

  <div id="SignUpModalForm">
      <form method="post" action="/signup" name="signupform" class="signupform"><p><label><strong>Choose a nickname</strong> (it cannot be changed later)<br><input type="text" value="" name="nick" maxlenght="60" class="inputsignup"></label></p><p><label><strong>What's your E-mail?</strong><br><input type="text" value="" name="semail" maxlenght="160" class="inputsignup"></label>  </p>   <p><label> <strong>Choose a password</strong><br>         <input type="password" name="pass" class="inputsignup">       </label>       </p>                             <p>       <label><input name="agree" class="check" type="checkbox" value="1"> I have read and agree with the <a href="/tos" target="_blank">Terms of Service</a>.</label>     </p>     <input type="hidden" name="modal" value="1" /><p class="buttons"><button type="submit">Create an account</button></p>   </form>
  </div>
    <div class="tutor_become">
  <a href="/online-tutoring-jobs">Become a tutor</a>
  </div>

</div>




<footer>
  <div id="footer">
    <div class="container">
        <ul class="main_links">
          <li><a href="/contact">Contact us</a></li>
                    <li><a href="http://blog.helphub.me">Blog</a></li>
                    <li><a href="/tutors-forum">Tutors Forum</a></li>
                    <li><a href="/campus-ambassadors">Campus Ambassadors</a></li>
          <li><a href="/group-tutoring">Group Tutoring</a></li>
          <li><a href="/press">Press</a></li>
          <li><a href="http://institutions.helphub.com/" target="_blank">For Institutions</a></li>
          <li><a href="http://blog.helphub.me/help-and-support/">FAQs</a></li>
          <li class="footer_social"><a href="http://twitter.com/HelpHubHQ" target="_blank"><i class="fa fa-twitter"></i></a></li>
          <li class="footer_social"><a href="http://facebook.com/HelpHubHQ" target="_blank"><i class="fa fa-facebook"></i></a></li>
        </ul>
        <ul class="footer_badges">
          <li class="phone"><i class="fa fa-envelope-o fa-2"></i> Questions? <a href="mailto:support@helphub.me">support@helphub.me</a></li>
          <li><a href="https://smarticon.geotrust.com/smarticonprofile?Referer=https://helphub.me"><img src="https://helphub.me/img/secured.png"></a></li>
          <li><a href="https://mixpanel.com/f/partner"><img src="https://cdn.mxpnl.com/site_media/images/partner/badge_light.png"></a></li>
        </ul>
        <ul class="footer_copy">
          <li><a href="/tos">Terms of Service</li>
          <li><a href="/privacy">Privacy Policy</a></li>
          <li><a href="/academic-policy">Academic Integrity Policy</a></li>
          <li><a href="/careers">Careers</a></li>
          <li class="copyright_copy">&copy; HelpHub Services Inc. 2013 - 2017 – All rights reserved.</li>
        </ul>
    </div>

    <script type="text/javascript">
    (function(d,s,i,r) {
      if (d.getElementById(i)){return;}
      var n=d.createElement(s),e=d.getElementsByTagName(s)[0];
      n.id=i;n.src='//js.hs-analytics.net/analytics/'+(Math.ceil(new Date()/r)*r)+'/473044.js';
      e.parentNode.insertBefore(n, e);
    })(document,"script","hs-analytics",300000);
  </script>
    </div>

</footer>
<div id="fb-root"></div>





<div id="TrialCallModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    // init the FB JS SDK
    FB.init({
      appId      : '279475605511244',                        // App ID from the app dashboard
      status     : true,                                 // Check Facebook Login status
      xfbml      : true                                  // Look for social plugins on the page
    });
        FB.Event.subscribe('edge.create', call_fb_like_tutor);
        // Additional initialization code such as adding Event Listeners goes here
  };

  // Load the SDK asynchronously
  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/en_US/all.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>



<script>(function(d, s, id) { 
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=279475605511244";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-1671208-29', 'helphub.me');
  ga('send', 'pageview');
     ga('set', '&uid', 3 );

</script>


<script type="text/javascript">
mixpanel.identify('39796');


</script>
<div id="video_call" class="modal-video-call hide" tabindex="-1" role="dialog"  aria-hidden="true">
          <div class="modal-body-video-call"></div>
</div>


<audio id="incomming" loop>
  <source src="sounds/incoming.ogg" type="audio/ogg">
  <source src="sounds/incoming.mp3" type="audio/mpeg">
</audio>

<audio id="im_new">
  <source src="/msgincoming.ogg" type="audio/ogg">
  <source src="/msgincoming.mp3" type="audio/mpeg">
</audio>

<audio id="outcomming" loop>
  <source src="sounds/outgoing.ogg" type="audio/ogg">
  <source src="sounds/outgoing.mp3" type="audio/mpeg">
</audio>
<script>
  $(window).scroll(function() {

    $('#video_animated').each(function(){
    var imagePos = $(this).offset().top;

    var topOfWindow = $(window).scrollTop();
      if (imagePos < topOfWindow+400) {
        $(this).addClass("slideRight");
      }
    });

    $('#phone_animated').each(function(){
    var imagePos = $(this).offset().top;

    var topOfWindow = $(window).scrollTop();
      if (imagePos < topOfWindow+400) {
        $(this).addClass("slideDown");
      }
    });
  });
</script>
<script type="text/javascript">
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0020/0846.js?"+Math.floor(new Date().getTime()/3600000);
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
</script>

<div id="hidden_id"></div>
<div class="searchresultsll displaynone footer_show_search">
  <div class="container">

  <form method="get" action="/search/" name="searchf" class="advanced_search">    

    <h4>Find a tutor: </h4>
      <span class='inputbox'>
        <label>Try Math, Chemistry, English...<br />

          <input class="search" value="" id="search" name="q" placeholder="Search tutors, subjects, or schools..." />
        </label>
      </span>


    <h4>Advanced search:</h4>
      <span class='inputbox'>

    <label>By School:<br />
      <input class="advanced_input" value="" name="network" placeholder="School name..." />
    </label>


    <label>By City or Location:<br />
      <input value="" class="advanced_input" name="city" placeholder="Add a city..." />
    </label>







      <label>Order by:<br />
        <select name="orderby" onchange="this.form.submit();" size="1" class="minimarginbotton">
<option value="relevance">Relevance</option>
<option value="lowest">Lowest rate</option>
<option value="highest">Highest rate</option>
        </select>
      </label>

      <button class="advanced_button" type="submit">Advanced Search</button>
      </span>
    </form>

  </div>
</div>
    <a href="#" id="my_iq" class="bottom_reputation">
    Your <em>Tutor Karma</em> is <strong>100</strong>
  </a>




<div id="lci">
  </div>
<div id="chat_bottom"></div>
<script type="text/javascript">
adroll_adv_id = "GCAP3UVPKVFMVG66HGCIS5";
adroll_pix_id = "AFRO7VQK2VAA7AI65I3LGG";
(function () {
var oldonload = window.onload;
window.onload = function(){
   __adroll_loaded=true;
   var scr = document.createElement("script");
   var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
   scr.setAttribute('async', 'true');
   scr.type = "text/javascript";
   scr.src = host + "/j/roundtrip.js";
   ((document.getElementsByTagName('head') || [null])[0] ||
    document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
   if(oldonload){oldonload()}};
}());
</script>

<script type="text/javascript">
  (function() {
    window._pa = window._pa || {};
        var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true;
    pa.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + "//tag.perfectaudience.com/serve/535058ae72bc7d6622000037.js";
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pa, s);
  })();
</script>
<script>(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
  _fbq.push(['addPixelId', '827515187325411']);
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', 'PixelInitialized', {}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=827515187325411&amp;ev=PixelInitialized" /></noscript>
<script type="text/javascript" src="https://helphub.me/d_base.js"></script>
<script type="text/javascript" src="https://helphub.me/jquery.scrollTo-1.4.3.1-min.js"></script>
<script type="text/javascript" src="https://helphub.me/jquery.fancybox.pack.js?v=2.1.4"></script>
<script type="text/javascript" src="https://helphub.me/jquery.fancybox-media.js?v=1.0.0"></script>
<script type="text/javascript" src="https://helphub.me/jquery.parallax-1.1.3.js"></script>
<script type="text/javascript" src="https://helphub.me/datepair.js"></script>
<script type="text/javascript" src="https://helphub.me/notify.min.js"></script>
<script type="text/javascript" src="https://helphub.me/jquery.timepicker.js"></script>
<script type="text/javascript" src="https://helphub.me/js/jquery.qtip.min.js"></script>
<script src="https://helphub.me/js/flatui-checkbox.js"></script>
<script src="https://helphub.me/js/flatui-radio.js"></script>
<script src="https://helphub.me/js/jquery.tagsinput.js"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="https://helphub.me/js/jquery.placeholder.js"></script>
<script src="https://helphub.me/js/jquery.stacktable.js"></script>
<script src="https://helphub.me/js/search_suggestions.js"></script>
<script src="https://helphub.me/js/jquery.geocomplete.js"></script>
<script type="text/javascript" src="https://helphub.me/javascript/jquery.fileupload.js"></script>
<script type="text/javascript" src="https://helphub.me/javascript/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="https://helphub.me/javascript/jquery.iframe-transport.js"></script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

提交登录页面后,通常会在页面重新加载或更新之前一段时间,因此您必须等待(不可靠 - 未知需要多长时间)或使用在页面加载完成后触发的回调:

page.onLoadFinished = function(){

    var currentUrl = page.evaluate(function() {
        return window.location.href;
    };

    // we're not on .../login page anymore
    // (if after login site redirects you elsewhere)
    if(currentUrl.indexOf("login") == -1) {
        // do stuff you want to do after login
    } else {
        // login here
    }
}

page.open("https://example.com/");