首页 > 解决方案 > Excel VBA Chrome Selenium 无法点击按钮

问题描述

如果使用 ChromeNoCache 子,Chrome 可以单击登录按钮。但是如果使用 ChromeCache 子,Chrome 无法单击登录按钮,我不知道为什么。请帮助使其单击“登录”按钮。

Public WD As New WebDriver

Sub ChromeNoCache() 'browser does NOT remember user and password for subsequent logins
        Call seleniumnocache("https://tap.revenue.wi.gov/mta/_/")
            WD.FindElementById("Dd-5").SendKeys "user"
            WD.FindElementById("Dd-6").SendKeys "password"
            WD.FindElementById("Dd-7").click  'This click works fine
End sub
Sub ChromeCache() 'browser remembers user and password for subsequent logins
        Call selenium("https://tap.revenue.wi.gov/mta/_/")
            WD.FindElementById("Dd-5").SendKeys "user"
            WD.FindElementById("Dd-6").SendKeys "password"
            WD.FindElementById("Dd-7").click  'This click is ignored by Chrome and does not work
End sub
Sub Selenium(curl)  'web will not ask for security code in subsequent logins
    On Error GoTo d1
    usernam = CreateObject("WScript.Network").UserName  '.ComputerName   .UserDomain
    Set oShell = CreateObject("WScript.Shell")
    spath = "C:\Users\" & usernam & "\AppData\Local\SeleniumBasic"  ' shm.Range ("i3")
    oShell.Run "chrome.exe -remote-debugging-port=9014 --user-data-dir=""""" & spath & """"""
    Set oShell = Nothing
    WD.SetCapability "debuggerAddress", "localhost:9014"
    WD.Start "Chrome", ""
    GoTo d2
    d1:
    WD.Start "Chrome", ""
    d2:
    WD.Get curl
End Sub

Sub seleniumnocache(curl)
    WD.Start "Chrome", ""
    WD.Get curl
End Sub


标签: excelvbaselenium

解决方案


推荐阅读