问题
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")
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 user 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 In</button>
</tr>
</tbody>
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
to read id's from html..plz help me...
回答1:
You use this to get the Element :
$oIE.document.getElementById($formUID)
And The Variable is defined as
$formUID = "username"
But, there is no Input Field or any other element with id="username"
or id="password"
in your HTML-Script
change this (line 3 and 5)
$formUID = "username"
$formPID = "password"
to this
$formUID = "usernameInput"
$formPID = "passwordInput"
回答2:
- Open IE
- Go to "Tools"
- Go to "Internet Options"
- Click on "Security" tab
- Uncheck the "Enable Protected mode" checkbox
- Restart IE and try your script
来源:https://stackoverflow.com/questions/23830280/autoit-script-is-not-taking-id-values-from-html-pages-when-i-am-using-ie10-windo