【问题标题】:Filling form input field with AutoIT使用 AutoIT 填写表单输入字段
【发布时间】:2016-02-27 11:37:44
【问题描述】:

尝试使用 AutoIT 自动填写亚马逊卖家中心的输入字段。一切都很好,但也许页面加载速度很慢,但我发送到表单输入元素的字符串被截断了。这是我的代码:

#include <IE.au3>



$oIE = _IECreate()
_IENavigate($oIE, "https://sellercentral.amazon.com/hz/home")
Local $oAddress = _IEPropertyGet($oIE, "locationurl")
ConsoleWrite($oAddress & @CRLF)
$oSignin = "https://sellercentral.amazon.com/gp/sign-in/sign-in.html?destination=https%3A%2F%2Fsellercentral.amazon.com%2Fhz%2Fhome"
if $oAddress = $oSignin Then
ConsoleWrite("Sucess! Connected!" & @CRLF)
Else
    ConsoleWrite("You are not on the sign in page")
EndIf
_IELoadWait($oIE)
Local $oForm = _IEFormGetObjByName($oIE, "signinWidget")
Local $oInputFile = _IEFormElementGetObjByName($oForm, "username")

; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")

; Select exisiting content so it will be overwritten

_IEAction($oInputFile, "selectall")


Send("12345678@asdfasdfdasfasd.com") 

【问题讨论】:

    标签: forms internet-explorer automation autoit


    【解决方案1】:

    您不想使用发送功能,因为它不是很可靠。请改用 _IEFormElementSetValue。大多数 IE 函数都有一个内置的加载等待函数,因此在网页加载之前它们不会执行下一行代码。

    此代码适用于我:

    #include <IE.au3>
    
    ;change this to your login info
    login("12345@gmail.com", "FakePass")
    
    Func login($sUserName, $UserPass)
        Local $oIE, $sSignin, $sAddress, $oForm, $oUserInput, $oUserPassInput
    
        $oIE = _IECreate("https://sellercentral.amazon.com/hz/home")
    
        $sAddress = _IEPropertyGet($oIE, "locationurl")
        ConsoleWrite($sAddress & @CRLF)
    
        $sSignin = "https://sellercentral.amazon.com/gp/sign-in/sign-in.html?destination=https%3A%2F%2Fsellercentral.amazon.com%2Fhz%2Fhome"
        If $sAddress = $sSignin Then
            ConsoleWrite("Sucess! On sign in page!" & @CRLF)
        Else
            ConsoleWrite("You are not on the sign in page" & @CRLF)
            Return
        EndIf
    
        $oForm = _IEFormGetObjByName($oIE, "signinWidget")
        $oUserInput = _IEFormElementGetObjByName($oForm, "username")
        $oUserPassInput = _IEFormElementGetObjByName($oForm, "password")
    
        ;set user name
        _IEFormElementSetValue($oUserInput, $sUserName)
    
        ;set pass
        _IEFormElementSetValue($oUserPassInput, $UserPass)
    
        _IEFormSubmit($oForm)
    EndFunc   ;==>login
    

    【讨论】:

      猜你喜欢
      • 2020-11-05
      • 2014-08-22
      • 2012-08-28
      • 2021-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多