Log in

View Full Version : [SLEEPER:] Fill detail in search box on website



krishak77
04-21-2019, 12:28 AM
Hello Everyone,

Can anyone help me on below situation

i want to give detail in search box on the webpage, but once open the website i am getting error and not filling text in searchbox, below code which i am using.


Sub lookupTest()
Dim appIE As InternetExplorerMedium
'Set appIE = Nothing
Dim objElement As Object
Dim objcollection As Object
Set appIE = New InternetExplorerMedium
sURL = "https://www.example.com"
With appIE
.Navigate sURL
.Visible = True
Do While appIE.Busy Or appIE.ReadyState <> 4
DoEvents
Loop
End With
Set objcollection = appIE.Document.getElementsByTagName("input")
i = 0
While i < objcollection.Length
If objcollection(i).id = "MscrmControls.Containers.RelevanceSearchControl-text-input-props" Then
' Set text for search
objcollection(i).Value = "12345"
End If
Do While appIE.Busy Or appIE.ReadyState <> 4
DoEvents
Loop
i = i + 1
Wend
Set appIE = Nothing
MsgBox (done)
End Sub


Element code is
"<input id="MscrmControls.Containers.RelevanceSearchControl-text-input-props" aria-label="Search box" data-id="MscrmControls.Containers.RelevanceSearchControl-text-input-props" placeholder="Search Dynamics 365 data" autocomplete="off" type="text" class="iq ct lt lu lv lw do lx if " value="">"

gohoga
02-21-2024, 02:43 AM
Some problems can occur:


Element id: Ensure that the id "MscrmControls.Containers.RelevanceSearchControl-text-input-props" is correct and has not been changed by other JavaScript code after the web page is loaded.
Timeout: Make sure you wait until the web page has finished loading before attempting to fill in the search box.
Error checking: Consider printing out the value of objcollection(i).id to ensure that you are selecting the correct element.
Check access: Sometimes accessing elements on a website requires access or authentication.
Check the above conditions to review and correct errors in your code.

tapirdumbo
04-18-2024, 07:43 PM
Make certain once the page loads, the id "MscrmControls.Containers.RelevanceSearchControl-text-input-props" is accurate and hasn't been altered by any other JavaScript code.