当我使用IE10 Windows8时,Autoit脚本不从HTML页面获取ID值吗? [英] Autoit script is not taking id values from html pages when i am using IE10 windows8?

查看:95
本文介绍了当我使用IE10 Windows8时,Autoit脚本不从HTML页面获取ID值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码从IE9中的html代码获取值,但是在IE10 Windows8中运行相同的脚本时,它不获取Id值并填充文本框.这是我的脚本

The following code takes values from html code in Ie9 but when run same script in Ie10 windows8 it not taking Id values and filling text boxes..here is my script

$url = "https://190.198.14.15/"
$formID = ""
$formUID = "username"
$uName = "admin"
$formPID = "password"
$pwd = "SeR^ER@iL0"
$formSubmit = "ID_LOGON"

;Launch the Internet Explorer as a private session
ShellExecute ("iexplore.exe", " -private about:blank", @programFilesDir & "\Internet Explorer\iexplore.exe", "open", @SW_MAXIMIZE)
WinWait ("Blank Page")
$oIE = _IEAttach ("about:blank", "url")

;Wait for the IE to launch
_IELoadWait ($oIE)

;Navigate to the given URL
_IENavigate ($oIE, $url)

;Get the IE process id specific to this instance
Local $PID = WinGetProcess(_IEPropertyGet($oIE, "hwnd"))

;Print the PID in the console
If $PID Then
    ;MsgBox(0, "Example", "Internet Explorer is running.")
    ;MsgBox(0,"Process ID",$PID)
    ConsoleWrite("["&$PID&"]")
Else
    MsgBox(0, "Example", "Unable to get the process id of IE instance")
EndIf

;Disable IE address bar and menu bar
_IEPropertySet ($oIE, "addressbar", False)
_IEPropertySet ($oIE, "menubar", False)

;Click on 'Continue to this website' option if there is any HTTPS certificate Warning
while(_IELinkClickByText ($oIE, "Continue to this website (not recommended)."))
        _IELoadWait ($oIE,10000)
wend

;Get the field id and fill with provided value
;$oIE.document.getElementById($formUID).value = $uName
$oIE.document.getElementsByName($formUID).Item(0).value = $uName
$oIE.document.getElementById($formPID).value = $pwd

;$oSubmit = _IEGetObjByName ($oIE, $formSubmit)
$oSubmit = $oIE.document.getElementById($formSubmit)
_IEAction ($oSubmit, "click")

这是我的html代码:

here is my html code:

<tbody>
    <tr>
        <td class="login_fields_lable" style="width: 34%;">
                <span id="usernameBox" style="white-space: nowrap; vertical-align: middle;" rel="localize[login.LocalUserName]">Local&nbsp;user&nbsp;name:</span>
            </td>

            <td class="login_fields">
                <input autocomplete="off" class="textfield" name="username" id="username" size="30" onkeypress="return checkEnter(event);" type="text">         </td>

    </tr>
    <tr>
        <td class="login_fields_lable" style="width: 34%;">
            <span id="passwordBox" style="vertical-align: middle;" rel="localize[login.password]">Password:</span>
        </td>

        <td class="login_fields">
            <input autocomplete="off" class="textfield" name="password" id="password" size="30" onkeypress="return checkEnter(event);" type="password">
        </td>
        <button id="ID_LOGON" name="ID_LOGON" type="button" onclick="signIn(); return false;" rel="localize[login.loginButton]">Log&nbsp;In</button>
    </tr>
</tbody>

由于html页面的设计没有表单标签,因此我遇到了问题:由于这个原因,我使用

as html page is designed without form-tag i am facing issue:because of that reason iam using

    $oIE.document.getElementById($formUID).value = $uName
$oIE.document.getElementById($formPID).value = $pwd

从html.plz读取ID可以帮助我...

to read id's from html..plz help me...

推荐答案

您可以使用它来获取Element: $oIE.document.getElementById($formUID)

You use this to get the Element : $oIE.document.getElementById($formUID)

并且变量定义为 $formUID = "username"

但是,HTML脚本中没有输入字段或其他任何带有id="username"id="password"的元素

But, there is no Input Field or any other element with id="username" or id="password" in your HTML-Script

更改此设置(第3行和第5行)

change this (line 3 and 5)

$formUID = "username"
$formPID = "password"

对此

$formUID = "usernameInput"
$formPID = "passwordInput"

这篇关于当我使用IE10 Windows8时,Autoit脚本不从HTML页面获取ID值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆