我正在尝试使用VBA excel自动化此网站。我很震惊,我必须从下拉框中选择值。我对VBA非常陌生,这是我的第一个这样的项目。这就是我编码选择值的原因。
Sub automaticformfilling_ASDA()
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 Title = i.e.document.getElementById("yourDetailsPolicyHolderTitle")
For i = 1 To Title.Options.Length
If Title.Options(i).Text = "Mrs" Then
Exit For
End If
Next i
End Sub
以下是该部分的HTML:
<select name="policyHolder.title" class="select-large" id="yourDetailsPolicyHolderTitle" data-di-field-id="policyHolderTitle">
<option selected="selected" value="">Please select</option>
<option value="NWA_PET_T5">Dr</option>
<option value="NWA_PET_T3">Miss</option>
<option value="NWA_PET_T1">Mr</option>
<option value="NWA_PET_T2">Mrs</option>
<option value="NWA_PET_T4">Ms</option>
</select>
答案 0 :(得分:0)
根据SJR的评论以及我在您的代码中发现的拼写错误,如果您使用此代码替换代码,那么它应该可以正常工作:
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/connect/{connectionToken}")
public Response doStuff(@PathParam("connectionToken") String token){
System.out.println(token);
//stuff..
}
您输入了iedocument.getElementByID,您应该拥有ie.document。