I have the next HTML code:
<input type="submit" name="ctl00$MainContent$btn_update" value="Update" onclick="return confirm('You are about to update the data. Are you sure?');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$btn_update", "", true, "Update_PL", "", false, false))" id="ctl00_MainContent_btn_update" class="normalButton" style="float: right; margin-right: 108px; margin-top: -3px; width: 130px; height: 50px; font-size: 24px;">
I have done a VB Script which take some actions in a web. The problem comes when I have to save these changes. To save them I've to click the button which code I posted above but, as you can see, it has an onclick event that throws an "Ok"/"Cancel" Pop-up.
I know how to click the button:
objIE.Document.getElementById("ctl00_MainContent_btn_update").Click()
but what I don't know how to do is to Click the "Ok" button shown below:
I have tried the next:
Activate the IE pop-up window and use SendKeys
objShell.AppActivate("Message from webpage")
objShell.SendKeys "{ENTER}"
Activate the IE pop-up window with the name shown on Windows Task Manager - Applications. But the problem here is that the IE Web window and the IE pop-up window have the same name in the Windows Task Manager, so AppActivate doesn't know which one to activate.
** Using sendkeys I've tried SendKeys "{ENTER}" and SendKeys"%K" but no successful result.
The interesting part of the VBS code is:
For Each a In .document.getElementsByTagName("a")
If InStr(a.GetAttribute("href"), linkToDetail)<> 0 And Not IsNull((InStr(a.GetAttribute("href"), linkToDetail))) Then
a.Click()
WaitWebLoad()
.document.getElementByID(editButton).Click()
WaitWebLoad()
.document.getElementByID(editArrivalDateTB).Value = activeSheet.Cells(rowIndex, columnArrivalDate).Value
.document.getElementByID(updateArrivalDateButton).Click()
'Something to press the OK button of the IE dialog window.
objShell.AppActivate(Window Title "- Internet Explorer")
WaitWebLoad()
objIE.document.getElementByID(backToSearchPL).Click()
WaitWebLoad()
Exit For
End If
Next
Done!
As I was not able to click the OK button, I have deleted the code doing the pop-up to rise.
objIE.document.getElementById("nameOfTheButton").onclick = ""
objIe.document.getElementById("nameOfTheButton").Click()