Попытка автоматизировать ввод данных в веб-приложение SAP с использованием IE и Excel VBA - PullRequest
0 голосов
/ 14 февраля 2020

Я могу войти в систему, однако я не могу выбрать какие-либо опции оттуда.

Пробное чтение на UI Automation, однако, не может последовать, может кто-нибудь помочь кодировать для клика

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

1 Ответ

0 голосов
/ 15 февраля 2020

Попробуйте это. Прочитайте мои комментарии в макросе:

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
...