AutoIt _IEAttach - 在 IE 模式下不匹配

问题描述 投票:0回答:0

首先,我打开一个网页,然后通过 Edge 在 IE 模式下重新加载。加载后,我想单击带有内部文本“登录”的登录按钮。

但是 autoit 说它无法获取窗口标题、url 或我尝试引用该窗口的任何其他内容。下面是我的代码,以网站为例。我已经使用 autoit 的窗口工具来查找其他信息。已尝试查看 _IEAttach 的文档。尝试过“url”、“title”、“Winlist”、“HWD”,但仍然无法将 IE 附加到网页。 我试过通过 Microsoft Edge 运行它然后让网页在 IE 中自动加载(我已经检查过它以便它始终以 IE 战斗模式加载,因为它需要运行网页)我试过通过互联网加载它探险家也是如此。我尝试过使用 Selenium 和 webdriver,但这对我也不起作用。所以我更喜欢使用自动它。

问题:IEAttach - 不匹配。有人可以帮忙吗?

另外,我曾经收到过这个错误-

C:\Program Files (x86)\AutoIt3\Include\IE.au3" (2111) : ==> 使用此对象请求的操作失败。: Return

SetError($_IESTATUS_Success, 0, HWnd($oObject.HWnd())) 返回

SetError($_IESTATUS_Success, 0, HWnd($oObject^ ERROR

退出代码:1

#include <IE.au3>

; Navigate to the URL in Internet Explorer
Run("C:\Program Files\Internet Explorer\iexplore.exe " & "https://site1.com")

Local $oIE = Null
; Wait for the webpage to load and open in IE mode
Do
    $title = "Site1"
    $hWnd = WinGetHandle($title)
    ;ConsoleWrite("Window title: " & $title & ", HWND: " & $hWnd & @CRLF)
    $oIE = _IEAttach($hWnd, "hwnd")
Until IsObj($oIE)

; Wait for the page to finish loading
_IELoadWait($oIE)

; Get all the button elements on the page
Local $oButtons = _IETagNameGetCollection($oIE, "button")

; Loop through the buttons to find the one with the Login text
For $oButton In $oButtons
    If StringStripWS(_IEPropertyGet($oButton, "innerText"), 8) = "Login" Then
        ; Click the Login button
        _IEAction($oButton, "click")
        ExitLoop
    EndIf
Next
internet-explorer webdriver autoit
© www.soinside.com 2019 - 2024. All rights reserved.