excel - 尝试使用 IE 和 excel vba 在 sap webapp 上自动输入数据
问题描述
我可以登录,但是我无法从那里选择任何选项。
尝试阅读 UI 自动化但无法遵循,有人可以帮助编写点击代码
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://website.com/"
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
IE.document.getElementById("j_username").Value = "user"
doc.getElementById("j_password").Value = "pass"
doc.getElementById("logOnFormSubmit").Click
Do While IE.Busy
Application.Wait DateAdd("s", 10, Now)
Loop
Dim NewTicketBtn As Object
Set NewTicketBtn = doc.getElementById("__tile0-__component0---landingDetail--aboPanel-2")
NewTicketBtn.Click
解决方案
尝试这个。阅读我在宏中的评论:
Sub test()
Dim IE As Object
Dim doc As HTMLDocument
Dim NewTicketBtn As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://website.com/"
Do While IE.Busy: DoEvents: Loop
Set doc = IE.document
doc.getElementById("j_username").Value = "user"
doc.getElementById("j_password").Value = "pass"
doc.getElementById("logOnFormSubmit").Click
'This don't work here because the ready state of the IE is allready 'complete'
'Do While IE.Busy
'Application.Wait DateAdd("s", 10, Now)
'Loop
'
'You must set a manual break for a few seconds to load the page after the login
'If 3 seconds not enough go higher
Application.Wait (Now + TimeValue("0:00:03"))
'Here you can't work anymore with 'doc' because the document in the IE has changed
Set NewTicketBtn = IE.document.getElementById("__tile0-__component0---landingDetail--aboPanel-2")
NewTicketBtn.Click
End Sub
推荐阅读
- flutter - Flutter:如何在listView的最后一个和第一个索引上隐藏和显示按钮
- javascript - 获取浏览器中所有现有内置变量的完整列表
- string - 根据分隔符拆分文件名给出语法错误:bash/sh 中的意外“(”(预期“完成”)
- java - 当我从用户那里获取输入时,为什么 java 会显示异常?
- matlab - 来自.txt文件matlab的字符串连接
- asp.net-core-mvc - @Model.Count() 可以计算状态名称之类的东西吗?
- javascript - 在 Next.js 中:如何将所有空路由重定向到我选择的路由
- reactjs - defaultProps 应该在类主体之外声明
- amazon-web-services - CDK rds 数据库集群和分配现有安全组
- google-bigquery - 如何在 GCP Bigquery 表中创建包含空格的列名?