I have task to automate filling of a web form. I am able open the form and able to select option from drop down and able to fill the form. Drop down have multiple options and show form according to the selection in the drop down. I able to select option from drop down through VBA coding but form is not expanding. Although It is get expanded through selection through mouse from drop down.
I have written the below code:
Sub FilltheForm1()
Dim IE As SHDocVw.InternetExplorer Dim IE2 As SHDocVw.InternetExplorer
Set IE = New InternetExplorer Set IE2 = New InternetExplorer
IE.Visible = True
IE.navigate "My URL"
Do While IE.readyState <> READYSTATE_COMPLETE Loop
Dim Doc As MSHTML.HTMLDocument
Set Doc = IE.document
Doc.getElementsByTagName("select").Item("userType").Value = "SERVICE_PROVIDER"
Doc.getElementsByTagName("Input").Item("firstName").Value = "A"
Doc.getElementsByTagName("Input").Item("middleInitial").Value = "A"
Doc.getElementsByTagName("Input").Item("lastName").Value = "A"
Doc.getElementsByTagName("select").Item("company").Value = "HCL"
Doc.getElementsByTagName("Input").Item("companyEmail").Value = "A"
Doc.getElementsByTagName("Input").Item("address").Value = "A"
Doc.getElementsByTagName("Input").Item("city").Value = "A"
Doc.getElementsByTagName("Input").Item("stateProvince").Value = "A"
Doc.getElementsByTagName("Input").Item("zipPostalCode").Value = "A"
Doc.getElementsByTagName("select").Item("country").Value = "INDIA"
Doc.getElementsByTagName("Input").Item("phone").Value = "A"
Doc.getElementsByTagName("textarea").Item("reasonForRequestingAccess").Value = "A"
End Sub
HTML Code of web Form:
<p class="pBold">User Type:<sup>*</sup></p></td>
<td colspan="2" align="left"> <select name='userType' class="selectDropDown" onChange=refreshPage()>
<option value= 'PLEASE SELECT USER TYPE' selected ="selected">
PLEASE SELECT USER TYPE
</option>
<option value= 'FUJI_XEROX'>
FUJI_XEROX
</option>
<option value= 'CONTRACT'>
OFF SHORE SERVICE DELIVERY
</option>
<option value= 'SERVICE_PROVIDER'>
SERVICE_PROVIDER
</option>
</select>
</td>
</tr>
Aucun commentaire:
Enregistrer un commentaire