Vbscript 使用vbs脚本登录后导航到新页面

Vbscript 使用vbs脚本登录后导航到新页面,vbscript,Vbscript,我不熟悉vb脚本,我在创建一个vb脚本时遇到问题,该脚本首先登录用户,然后在登录后导航到某个页面 下面的脚本打开IE,然后导航到登录页面,输入用户名和密码,然后单击“登录”按钮 请有人告诉我如何添加到这个脚本?我想在用户登录后将其发送到某个页面 WScript.Quit Main Function Main Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") IE.Visible = True I

我不熟悉vb脚本,我在创建一个vb脚本时遇到问题,该脚本首先登录用户,然后在登录后导航到某个页面

下面的脚本打开IE,然后导航到登录页面,输入用户名和密码,然后单击“登录”按钮

请有人告诉我如何添加到这个脚本?我想在用户登录后将其发送到某个页面

WScript.Quit Main

Function Main
  Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
  IE.Visible = True
  IE.Navigate "http://examplewebsite.com"
  Wait IE
  With IE.Document
    .getElementByID("UserName").value = "username"
    .getElementByID("Password").value = "password"
    IE.Document.All.Item("login-submit-button").Click
  End With
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy
End Sub

Sub IE_OnQuit
  On Error Resume Next
  WScript.StdErr.WriteLine "IE closed before script finished."
  WScript.Quit
  End Sub  
登录成功,我可以通过单击所需页面的链接手动导航到所需页面,但我似乎无法在脚本中自动导航到该页面。 我们衷心感谢您的帮助

非常感谢,, 詹姆斯

编辑-网站的源代码

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>Trakline Dashboard Portal</title>
    <link rel="shortcut icon" href="http://london.trakline-ats.co.uk/resources/images/favicon48.ico" type="image/x-icon" />
    <link rel="shortcut icon" type="image/png" href="http://london.trakline-ats.co.uk/resources/images/CustomIcons/96px/favicon.png" />

    <!-- For iPhone 4 with high-resolution Retina display: -->
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/resources/images/mobile/home114.png" />
    <!-- For first-generation iPad: -->
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/resources/images/mobile/home72.png" />
    <!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: 57x57-->
    <link rel="apple-touch-icon-precomposed" href="/resources/images/mobile/home57.png" />


    <meta name="application-id" content="Ats" />
    <meta name="application-name" content="Trakline Dashboard" />
    <meta name="msapplication-task" content="name=Dashboard;action-uri=http://london.trakline-ats.co.uk/Home/Index/1;icon-uri=http://london.trakline-ats.co.uk/resources/images/favicon48.ico" />
    <meta name="msapplication-task" content="name=Driver;action-uri=http://london.trakline-ats.co.uk/Driver/Index;icon-uri=http://london.trakline-ats.co.uk/resources/images/favicon48.ico" />
    <meta name="msapplication-task" content="name=Place;action-uri=http://london.trakline-ats.co.uk/Place/Index;icon-uri=http://london.trakline-ats.co.uk/resources/images/favicon48.ico" />
    <meta name="msapplication-task" content="name=Resource;action-uri=http://london.trakline-ats.co.uk/Resource/Index;icon-uri=http://london.trakline-ats.co.uk/resources/images/favicon48.ico" />
    <meta name="msapplication-task" content="name=Tracking;action-uri=http://london.trakline-ats.co.uk/Tracking/Index;icon-uri=http://london.trakline-ats.co.uk/resources/images/favicon48.ico" />
    <meta name="msapplication-task" content="name=Job Management Summary;action-uri=http://london.trakline-ats.co.uk/Work/JobManagementSummary;icon-uri=http://london.trakline-ats.co.uk/resources/images/favicon48.ico" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />


<link rel="stylesheet" type="text/css" href="/Content/bundles/DefaultCss?v=5yfqfmmmlZJHRL7LnThimyGpnaudP_rjY0267sKWKCs1" />
<link rel="stylesheet" type="text/css" href="/Content/bundles/BootstrapCss?v=U8XMYNxuaH-VgydGMd0j-UlPVtSRmGgzgAeLpBb9PzA1" />
<link rel="stylesheet" type="text/css" href="/Content/bundles/MapCss?v=_NG0UPFwckHnB0mbnxCHfABwf4bb0swcSlUOmSbgnpg1" />
<link rel="stylesheet" type="text/css" href="/Content/bundles/DataTablesCss?v=RfwLQxGDTuOKhHht1soeL-FFxjkoS9dp2lDPjjt4Q-g1" /> 

<!--[if lte IE 9]>    
    <link rel="stylesheet" type="text/css" href="/Content/default/Bootstrap/css/bootstrap-ie9.css" />
<![endif]-->

<!--[if lte IE 8]>
    <link rel="stylesheet" type="text/css" href="/Content/default/Bootstrap/css/bootstrap-ie8.css" /> 
<![endif]-->

<!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="/Content/default/Bootstrap/css/bootstrap-ie7.css" /> 
<![endif]-->

    <link href="/Zip/Style/8_12_0_HF01?Path=dAAAAB%2BLCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee%2B%2B997o7nU4n99%2F%2FP1xmZAFs9s5K2smeIYCqyB8%2FfnwfPyLunlTLNl%2B2d6vLvK6LWX73rKnaOnt796d%2F0Tqvr7fXxfbueHdnfG88XTdttRhPm%2BZnht%2F6wQ9%2BELaY5efZumzvNvl0XeczfPn%2FBAAA%2F%2F%2Fyf7AEdAAAAA%3D%3D" type="text/css" rel="stylesheet" /> 
    <!--[if lt IE 9]><link href="/Zip/Style/8_12_0_HF01?Path=JgAAAB%2BLCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee%2B%2B997o7nU4n99%2F%2FP1xmZAFs9s5K2smeIYCqyB8%2FfnwfPyLunlTLNl%2B2d2f5ebYu27tPq6vlRZ3N8id1ddXk9cF42jT%2FTwAAAP%2F%2FM%2FnnIiYAAAA%3D" type="text/css" rel="stylesheet" /><![endif]-->
    <!--[if lt IE 8]><link href="/Zip/Style/8_12_0_HF01?Path=JgAAAB%2BLCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee%2B%2B997o7nU4n99%2F%2FP1xmZAFs9s5K2smeIYCqyB8%2FfnwfPyLunlTLNl%2B2d2f5ebYu27tPq6vlRZ3N8id1ddXk9YPxtGn%2BnwAAAP%2F%2F4m63oCYAAAA%3D" type="text/css" rel="stylesheet" /><![endif]-->
    <!--[if lt IE 7]><link href="/Zip/Style/8_12_0_HF01?Path=JgAAAB%2BLCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee%2B%2B997o7nU4n99%2F%2FP1xmZAFs9s5K2smeIYCqyB8%2FfnwfPyLunlTLNl%2B2d2f5ebYu27tPq6vlRZ3N8id1ddXk9afjadP8PwEAAP%2F%2FUkfXnSYAAAA%3D" type="text/css" rel="stylesheet" /><![endif]-->


</head>
<body class="secured">
    <div class="page">
        <div id="header">
            <h1>
            </h1>
        </div>
        <div id="main">
            <p>
    <img src="/resources/images/default/logo.png" alt="Trakline" title="Trakline" />
</p>

<p>
    Please enter your username and password.
</p>

<form action="/Account/Logon" id="login-form" method="post"><input data-val="true" data-val-required="The IsForgottenPassword field is required." id="IsForgottenPassword" name="IsForgottenPassword" type="hidden" value="False" /><input Value="0" data-val="true" data-val-number="The field LogOnAttemptCount must be a number." data-val-required="The LogOnAttemptCount field is required." id="LogOnAttemptCount" name="LogOnAttemptCount" type="hidden" value="0" /><input Value="0" data-val="true" data-val-number="The field CaptchaAuthenticationId must be a number." data-val-required="The CaptchaAuthenticationId field is required." id="CaptchaAuthenticationId" name="CaptchaAuthenticationId" type="hidden" value="0" /><input Value="False" data-val="true" data-val-required="The ShowCaptcha field is required." id="ShowCaptcha" name="ShowCaptcha" type="hidden" value="False" />    <fieldset class="ui-state-default ui-corner-all">
        <div class="editor-label">
            <label for="UserName">Username</label>
        </div>
        <div class="editor-field">
            <input data-val="true" data-val-required="The Username field is required." id="UserName" maxlength="32" name="UserName" type="text" value="" />
            <span class="field-validation-valid" data-valmsg-for="UserName" data-valmsg-replace="true"></span>
        </div>
        <div class="editor-label">
            <label for="Password">Password</label>
        </div>
        <div class="editor-field">
            <input autocomplete="off" data-val="true" data-val-required="The Password field is required." id="Password" name="Password" type="password" />
            <span class="field-validation-valid" data-valmsg-for="Password" data-valmsg-replace="true"></span>
        </div>
        <input type="submit" value="Log On" id="login-submit-button" />

        <a id="forgotten-submit-button" href="#">Forgotten Password</a>
    </fieldset>
    <div id="downgradeCompatWarning"></div>
</form>
            <div id="footer">
            </div>
        </div>
    </div>
    <div id="buildDetails">
    <div id="buildDetailsSummaryLink">
        <a href="#" id="buildDetailsLink" title="Toggle build information">?</a>
    </div>
    <div id="buildDetailsSummary">
        <dl>
                            <dd>BuildVersion: "8.12.71.429"</dd>
                            <dd>HotFix: "8_12_0_HF01"</dd>
                <dd>BuildDate: "12/22/2014 00:32:04"</dd>
                <dd>RenderDate: "02/24/2015 16:03:54"</dd>
        </dl>
    </div>
</div>

    <script type="text/javascript" src="/Zip/Script/8_12_0_HF01?Path=BAIAAB%2BLCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee%2B%2B997o7nU4n99%2F%2FP1xmZAFs9s5K2smeIYCqyB8%2FfnwfPyLuvp7Wxapt7k7XTVst7p4uL4u6Wi7yZev%2F%2FpNZXWSTMm%2FGP938jH3np3%2FROq%2Bvt3fHD8c7kS%2FG62U1aet1U1zm29lPZ%2B%2FGi2IZa3eZlcUsa%2FOxILGxiQczaKf4S%2FOviu2XdV5W2SyG77oglHd3OjgrgFVdtVV7veoMtWiqts7eGgxnRVZWF7H3szKv2%2BCL7%2FwEej191%2BbLpqiWdkgvs6a5qurZ67bOlxftPAZtUldXTV4%2Fzdt82tLLw0MeGwxXCjbW9FXeVOt6mjfut%2FFPN%2F9PAAAA%2F%2F9Zc2F%2FBAIAAA%3D%3D"></script><script type="text/javascript" src="/Zip/Script/8_12_0_HF01?Path=dQAAAB%2BLCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee%2B%2B997o7nU4n99%2F%2FP1xmZAFs9s5K2smeIYCqyB8%2FfnwfPyLuNtO6WLXN3em6aavF3VV2kTd3j6fTar1s777Mmuaqqmcn82x5kY9%2FuvmZze2fVxfVkpu9Dps9WRfl7E11cVECyv8TAAD%2F%2F2%2FH3511AAAA"></script>



    <script type="text/javascript" src="/Zip/Script/8_12_0_HF01?Path=FwAAAB%2BLCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee%2B%2B997o7nU4n99%2F%2FP1xmZAFs9s5K2smeIYCqyB8%2FfnwfPyLuvp7Wxapt7k7XTVst7p5UdT7%2B6eb%2FCQAA%2F%2F9BgP%2BAFwAAAA%3D%3D"></script>

</body>
</html>
试着这样做:

Option Explicit
Dim IE,Helem
Set IE = CreateObject("InternetExplorer.Application") 
IE.Visible = 1  
IE.navigate "http://www.example.com/login" 
Do While (IE.Busy) 
    WScript.Sleep 10 
Loop 
Set Helem = IE.document.getElementById("UserName") 
Helem.Value = "NomUtilisateur" 
Set Helem = IE.document.getElementById("Password") 
Helem.Value = "MotDePasse" 
Set Helem = IE.document.Forms(0) 
Helem.Submit

您应该至少向我们提供您网站的链接或其源代码。谢谢Hackoo,我已将网站源代码添加到原始帖子中。你好,Hackoo,谢谢此代码似乎是填写表单和登录的另一种方式-但是,登录后如何导航到另一个页面并将其包含在上述脚本中?
Option Explicit
Dim IE,Helem
Set IE = CreateObject("InternetExplorer.Application") 
IE.Visible = 1  
IE.navigate "http://www.example.com/login" 
Do While (IE.Busy) 
    WScript.Sleep 10 
Loop 
Set Helem = IE.document.getElementById("UserName") 
Helem.Value = "NomUtilisateur" 
Set Helem = IE.document.getElementById("Password") 
Helem.Value = "MotDePasse" 
Set Helem = IE.document.Forms(0) 
Helem.Submit