Fog Creek Software
Discussion Board




Automating IE For Testing

Hi, I'm using the InternetExplorer.Application object to automate IE so I can "black box" test a live website.

All goes well except that at one point in the site a javascript alert dialog will pop up. How can I automate IE so that it will click (or dismiss) this alert box?

Matthew Lock
Tuesday, February 03, 2004

Usually a required dialog box is designed to protect users. It prevents malicious scripts from: 1) installing IE plug-ins without permissions; 2) change home page, 3) add bookmark, 4) mail email, 5) read cookies that don't belong to your scope. You aren't suppose to bypass them.

Li-fan Chen
Tuesday, February 03, 2004

I don't want to "bypass" it exactly, I just want my program, which is automating IE to be able to click "ok" on the javascript dialog.

The alert is just one of those javascript ones like:

alert("Welcome to my site");

Matthew Lock
Tuesday, February 03, 2004

Since you test the IE from outside the sand box, did you try to get the message box window handle and to send it a WM_DESTROY?

coresi
Tuesday, February 03, 2004

I just did it from the OLE InternetExplorer.Application thing from perl, I'm not entirely sure if I can get window handle like this. I guess I was hoping there was some method of that object which would click javascript dialogs.

Matthew Lock
Tuesday, February 03, 2004

Windows Scripting Host sendKeys?

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q259/1/03.ASP&NoWebContent=1


Tuesday, February 03, 2004

Maybe the sendkeys could work. I can get the HWND of the IE window that my script creates.

Matthew Lock
Tuesday, February 03, 2004

I've seen freeware or sharaware programs that could send events to windows, based on title and other parameters.

Egor
Tuesday, February 03, 2004

Looks like Rational Test (ex MS Test, ex Visual Test) got the ax after Rational was bought by IBM... Too bad, because it was a neat program to write tests in Basic

http://www-306.ibm.com/software/rational/offerings/testing.html

FredF
Tuesday, February 03, 2004

Silk test is way better than Visual Test ever was.....

http://www.segue.com/html/s_solutions/s_silktest/s_silktest_toc.htm

GenX'er
Tuesday, February 03, 2004

I used to use an automated gui tester that was an internal tool.  It was really easy to use and fully scripted for IE, and instead of passing around messages, it actually located buttons on the screen, and provided mouse/keyboard input.  Benefit, you rearrange your whole screen it still works, and it actually walks through the GUI like a user would.  I can't remember the name of the tool for the life of me.  When I get home I'll pull up the name, and maybe you could find it through Google.  The only downside was it didn't work with just the rendering engine (i.e. for windows help type features).  I think it worked with the activex component though.

Elephant
Tuesday, February 03, 2004

"I've seen freeware or sharaware programs that could send events to windows, based on title and other parameters. "

http://www.12ghosts.com/ghosts/robo.htm
"Every time a new window appears this robot checks if you want to close it, move it, or click a button automatically."

$30

I don't recall any freeware apps that might do this, though some macro programs may. I know you probably want a programming solution, but sometimes you just gotta do what works.

Full name:
Tuesday, February 03, 2004

I've done something similar with a few Win32 calls.  First, use FindWindowEx to locate the alert box (use Spy++ to figure out the window class if you can't distinguish the window with only the caption).  Then use FindWindowEx with the alert box hwnd to find the OK button.  Then send the appropriate message to simulate a key press or mouse click (the SendInput API does it). 

SomeBody
Tuesday, February 03, 2004

*  Recent Topics

*  Fog Creek Home