Я использую VBA и пытаюсь ввести значение в поле ввода с веб-страницы. После ввода значения, когда я нажимаю кнопку отправки, значение сбрасывается. Я попробовал несколько методов и функций, таких как .focus, .change или .keydown.
Строка для поля ввода выглядит следующим образом:
<"input ng-if=":: !uiInputNumberIncrementerCtrl.isTouchSupported" type="text" class="stepper-value ng-pristine ng-valid ng-scope ng-not-empty ng-valid-rate-validator ng-touched" ng-model="uiInputNumberIncrementerCtrl.inputValue" ng-model-options="{updateOn: 'blur' }" data-input-box="" ng-focus="focus($event)" ng-keydown="keydown($event)" ng-change="blur($event)" ng-blur="defocus($event)" data-maxchars="12" data-number="" data-input-scrollto="" data-etoro-automation-id="input"">
Private Sub Watchlist_Information()
Dim IE As Object
Dim IE_Port As Object
Dim Doc As Object
Dim objElement As Object
Dim objCollection As Object
Dim objSubCollection As Object
Dim buttonCollection As Object
Dim evt As Object
Dim valeur_heure As Object
Dim Wks As Workbook
Dim MBoard As Worksheet
Set Wks = ThisWorkbook
Set MBoard = Wks.Sheets("MBoard")
Dim i As Long
Dim RowRef As Long
Dim SelectedStock As Integer
RowRef = 11
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
' You can uncoment Next line To see form results
IE.Visible = True
' Send the form data To URL As POST binary request
IE.navigate "https://www.etoro.com/watchlists"
' Wait while IE loading...
While IE.Busy
DoEvents
Wend
' Configuration for input boxes that require Keyboards inputs
Set evt = IE.document.createEvent("keyboardevent")
evt.initEvent "change", True, False
Application.Wait (Now + TimeValue("0:00:06"))
'Find the slected stock based on ticker and issue a buy order
Set objCollection = IE.document.getElementsByClassName("ng-scope")
i = 0
While i < objCollection.Length
If objCollection(i).childElementCount > 0 Then
If objCollection(i).Children(0).childElementCount > 1 Then
If objCollection(i).Children(0).Children(0).childElementCount > 0 Then
If objCollection(i).Children(0).Children(1).Children(0).innerText = MBoard.Range("D3").Value Then
objCollection(i).Children(1).Children(2).Children(1).Children(0).Click
SelectedStock = i
End If
End If
End If
End If
i = i + 1
Wend
IE.document.getElementsByClassName("box-tab-value ng-binding ng-scope")(1).Click
IE.document.getElementsByClassName("box-tab-value ng-binding ng-scope")(2).Click
Set evt = IE.document.createEvent("keyboardevent")
evt.initEvent "change", False, True
Set objCollection = IE.document.getElementsByClassName("stepper")
objCollection(2).Children(1).Focus
objCollection(2).Children(1).dispatchEvent evt
objCollection(2).Children(1).Keydown
objCollection(1).Children(1).Value = MBoard.Range("F17").Value
objCollection(2).Children(1).Keydown
objCollection(2).Children(1).Change
objCollection(2).Children(1).Focus
objCollection(2).Children(1).Blur
IE.document.getElementsByClassName("ng-isolate-scope")(3).Click
У меня нет сообщений об ошибках,Значение просто сбрасывается при нажатии кнопки отправки.