我正在使用vba在Internet Explorer中自动化Web表单归档站点。到目前为止我一直非常成功。我遇到的问题是有一个输入字段,类型是"隐藏"而不是文字。运行第一个代码后,第二个字段将自动填充,直到现在才隐藏。它仅在我们在前一个字段中输入值时填充。这是一个下拉字段,因此我们需要从下拉列表中选择值。因此,当我尝试自动化时,隐藏字段不会自动填充,因为在手动过程中就是这种情况。我该如何解决这个问题?我知道必须有办法。
这是我正在使用的代码。
Sub automaticformfilling_ARGOS()
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
'to make sure that the website is properly loaded
With ie
.Visible = True
.navigate "https://www.argos-pet-insurance.com/quoteAndBuy.do?e=e1s1&curPage=captureDetails&rakT=1510852044896.1391473424.994101.1731.881880349.846|tsid:9904"
Do While .Busy
DoEvents
Loop
Do While .readyState <> 4
DoEvents
Loop
End With
Set BreedType = ie.document.getElementById("yourDetailsPolicyHolderBreedTypes0")
BreedType.selectedIndex = 2
Set BreedName = ie.document.getElementById("breedTypeAhead")
BreedName.selectedIndex = 1
End Sub
第一个字段的HTML代码是
<select name="pets[0].breedType" class="select-large changeTriggered"
id="yourDetailsPolicyHolderBreedTypes0" onchange="FormTaggingMain('',
1500);" data-di-field-id="pets0BreedType"><option
id="petBreedTypesSelectVoidOption" selected="selected" value="">Please
select</option><option id="petBreedTypesSelectOptions1"
value="NWA_PET_C">Cross Breed</option><option
id="petBreedTypesSelectOptions2" value="NWA_PET_P">Pedigree</option><option
id="petBreedTypesSelectOptions3" value="NWA_PET_S">Small mixed breed (up to
10kg)</option><option id="petBreedTypesSelectOptions4"
value="NWA_PET_B">Medium mixed breed (10 - 20kg)</option><option
id="petBreedTypesSelectOptions5" value="NWA_PET_L">Large mixed breed (above
20kg)</option></select>
隐藏字段的HTML代码是
<input class="typeahead large-input hasPlaceholder tt-input"
id="breedTypeAhead" style='vertical-align: top; position: relative;
background-image: ur("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
"); background-color: transparent;' dir="auto" spellcheck="false"
onblur="breedChange(this);" onchange="breedChange(this);
placeholder="Please start typing" value="" autocomplete="off">