UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Getting An Html Element, Any Versions    
 
   
JimCarney6
post Dec 4 2018, 02:42 PM
Post#1


UtterAccess VIP
Posts: 1,943
Joined: 9-September 02
From: Florida


I have been trying to fill a text box on a web page & I think i'm not identifying it right. I login to it & click the button to take me to the search screen, all just fine, just like i'm doing it by hand. I see the box I want, its 1 of 3, first on the left. when I inspect element on it, I get the following:

<ng-transclude>
<input name = "" tabindex="0" class="ng-pristine ng-valid ng-scope ng-touched" aria-invalid="false" type="text" ng-model="policySearchRequestView.policyNumber.value" ng-keypress="($event.which === 13)?searchPolicies():0">
</ng-transclude>

I have scrolled thru the elements by tag name looking for "input" as so:
Set HTMLInputs = HTMLDoc.getElementsByTagName("input")
''Set HTMLInputs = HTMLDoc.getElementById("personPolicy")
For Each HTMLInput In HTMLInputs
Debug.Print "ClassName:" & HTMLInput.className, "TagName:" & HTMLInput.tagName, "ID:" & HTMLInput.Id, "InnerText:" & HTMLInput.innerText, "Href:" & HTMLInput.getAttribute("href"), "rel:" & HTMLInput.getAttribute("rel")

Next HTMLInput
HTMLInput(13).value = "9509966270" 'policy number to search:9509966270

it gave me a list as such
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:Policies InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:inGoodStandingPolicies InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:delinquentPolicies InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:In ForcePolicies InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:ScheduledPolicies InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:CanceledPolicies InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:Quotes InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:Renewal InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:Change InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:Cancellation InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid TagName:INPUT ID:HomeownersLine_HOE InnerText: Href: rel:
ClassName: TagName:INPUT ID: InnerText: Href: rel:
ClassName: TagName:INPUT ID: InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid ng-scope TagName:INPUT ID: InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid ng-scope TagName:INPUT ID: InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid ng-scope TagName:INPUT ID: InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid ng-scope gw-no-label gw-first TagName:INPUT ID:personPolicy InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid ng-scope gw-no-label gw-second TagName:INPUT ID:companyPolicy InnerText: Href: rel:
ClassName:ng-pristine ng-untouched ng-valid ng-scope ng-valid-maxlength TagName:INPUT ID: InnerText: Href: rel:

I believe what I want is the 13th in the index, but I've tried 13, 16th & trying to get the ID for personPolicy which seems like a choice on the ID.

what is a better way for me to narrow down the field I need to update. thank you!


as an edit: when I use
Set HTMLInput = HTMLDoc.getElementById("personJob")
HTMLInput.value = "9509966270"
it doesn't throw any error at me like the item doesn't exist, but it also doesn't appear to change the value of anything on screen.
-Jim

-Jim


one more edit: I do find this element: .search-module .form .gw-control-group-wrapper .form-item-grid-fli input. it does light up all three fields in chrome, but i'm not sure how to reference it, if in fact its useful.

thank you!
Go to the top of the page
 
JimCarney6
post Dec 4 2018, 09:04 PM
Post#2


UtterAccess VIP
Posts: 1,943
Joined: 9-September 02
From: Florida


ok, i was able to use the following on a control group
Set HTMLInputs = HTMLDoc.getElementsByClassName("gw-control-group")
'Set HTMLInputs = HTMLDoc.getElementsByTagName("input")
For Each HTMLInput In HTMLInputs
Debug.Print "ClassName:" & HTMLInput.className, "TagName:" & HTMLInput.tagName, "ID:" & HTMLInput.Id, "InnerText:" & LTrim(HTMLInput.innerText)
If InStr(HTMLInput.innerText, "Policy") > 0 Then
HTMLInput.value = "9509966270"
Exit For
End If
Next HTMLInput

however the HtmlInput.value line fails. so apparently the item i'm looping thru isn't an input box. the text onscreen is above the field i want. Maybe it's a label? can i get at the field it's attached to?
thank you!
-Jim
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    19th October 2019 - 02:06 AM