1

I'd like to click on "OK" to a popup javascript question.

Here is my html file (c:\temp\test.html):

<HTML>
  <HEAD>
    <SCRIPT LANGUAGE="javascript">
      confirm( "Please click OK" );                     
    </SCRIPT>       
  </HEAD>
</HTML>

and here is the starting of a basic vbs file to open the html file (c:\temp\test.vbs) :

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate ("file:///C:/temp/test.html")

How to click on the "Ok" button by completing the vbs file?

Edit : The html cannot be changed cause he's from a robotic hardware and the manufacturer don't allow anykind of change in their code (the .html sample code in my post is just an exemple of what kind of msgbox they use)

the "sendkey" option is a good alternative, but in my case i cannot do this on the server. the vbscript is a long harder than the vbscript i've post, and in experience the "sendkey" option does not give 100% exact result (if the msgbox does not displayed and i sendkey "enter", it can do critical stuffs). i'm going more in that kind of command line : ie.Document.all.Item("Ok").Click , but i didn't find an alternative for javascript "confirm" msgbox type.

3
  • 3
    What are you really trying to achieve? What is the end goal? Commented Oct 15, 2013 at 14:15
  • Hi @inoujk, not sure if you saw my message, but if you want to add more information, please edit it into your question. If it's just a few lines, add it as a comment to the user's answer but don't post a separate answer unless you're actually answering the question. Hope this helps! :) Commented Nov 3, 2013 at 17:58
  • thx for explain me why my answer was bloqued.. i'm going to edit my post^^ Commented Nov 5, 2013 at 13:33

1 Answer 1

1

The way you would do this would either be by using SendKeys or by using a different type of "confirm" box.

SendKeys, put this after the IE.Navigate:

Set objShell = CreateObject("Wscript.shell")
objShell.AppActivate("c:\temp\test.html")
WScript.Sleep 100
objShell.SendKeys "{ENTER}"

Different type of confirm:

add this to the .html

<input type="submit" id="Confirmed" value="Yes" onClick="runConfirmCode">
<input type="button" id="NotConfirmed" value="No" onClick="runNotConfirmedCode">

then in the .vbs add this after IE.Navigate

IE.Document.getElementByID("Confirmed").click
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.