Hello experts,
I need help to select the "I agree" radio button on a website. I tried many ways found on the Internet but I couldn't get it to work, so I give up and I am here to find a solution.
The steps are the following:
-Login (done)
-Agree the terms (Here is the problem)
-Start to work (I guess this gonna be easy)
Here is the code I am using to login (the next page is the Agreement):
Private Sub Label1_Click()
If Me.TextBox1.Value = "" Then MsgBox "You must enter a Sender ID.", vbExclamation, "Sender ID is Empty...": Exit Sub
If Me.TextBox2.Value = "" Then MsgBox "You must enter the Password.", vbExclamation, "Password filed is Empty...": Exit Sub
If Me.TextBox1.Value <> "I CAN'T SHOW THIS" Then
MsgBox "You entered an incorrect Sender ID.", vbCritical, "Wrong Sender ID..."
Me.TextBox1.BorderColor = vbRed
Exit Sub
Else
GoTo checkPass
End If
checkPass:
If Me.TextBox2.Value <> "I CAN'T SHOW THIS" Then
MsgBox "You entered the wrong Password.", vbCritical, "Wrong Password..."
Me.TextBox2.BorderColor = vbRed
Exit Sub
Else
GoTo accessLogin
End If
accessLogin:
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "https://eapis.cbp.dhs.gov/"
Do Until .ReadyState = 4
DoEvents
Loop
.Document.all.Item("username").Value = Me.TextBox1.Text
.Document.all.Item("password").Value = Me.TextBox2.Text
.Document.forms(0).submit
End With
End Sub
And here is the code I got from the "Inspect Element" of Google Chrome in the webpage:
<div class="tworadios">
<span class="radio1"><input type="radio" name="agreement" value="1">I agree</span>
<span class="radio2"><input type="radio" name="agreement" value="2" checked="checked">I disagree</span>
</div>
This is the code following the above (Is where the "Next" button appears, to agree the terms and continue, but I guess I must use .Document.forms(0).submit to continue):
<div id="navigation">
<span></span>
<input class="navbutton" type="image" src="img/btn_next.gif" name="next" value="Next">
</div>
Bookmarks