excel - 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
解决方案
推荐阅读
- c# - 为什么在运行时肯定会失败的 List.Sort 编译?
- html - 如何调整 CSS 以使关闭按钮看起来在正确的位置?
- c# - 如何从存储为 C# 中的对象的对象 [] 进行转换
- javascript - ReactJS/Javascript:componentDidMount() 和渲染
- linux - 如何根据修改时间对Cent OS 7目录中具有特定扩展名的所有文件进行排序?
- javascript - 异步更新 Zabuto 日历
- python-3.x - 为什么在尝试解码我的 base32 字符串时出现“不正确的填充”错误?
- json - 在 Hyperledger Fabric 中存储 JSON 文档
- c# - 如何查询特定类型然后获取基础文档
- javascript - 创建新数组产生未定义的函数