[Wtr-general] how to check security alert box before clicking it

Amit forum-watir-users at openqa.org
Wed Jul 4 12:50:51 EDT 2007


I resolved the problem. actually we have to check for the getWindowHandle("Security Alert") in a loop. first time it didn't find the window.

The code i used is - 
*		begin*
*			wc = WinClicker.new*
*			hwnd = wc.getWindowHandle("Security Alert")*
*			if(hwnd == -1) then*
*			num = 0*
*			while( num < 1)*
*				hwnd = wc.getWindowHandle("Security Alert")*
*				num = num + 1*
*			end*
*			end* 
*			if(hwnd != -1) then* 
 *				wc.clearSecurityAlertBox()*
 *				startAction "Recived Security Alert", " Click 'Yes' button"*
 *				logPass*
*			else*
*				startAction "No Security Alert", "No Action"*
*				logPass*
*			end*
*		rescue => e*
*			startAction "Security Alert throws exception", "Exception for Security Alert window"*
*			handleFail e*
*		end*

Now its working. If security Alert window is not present it will not call *wc.clearSecurityAlertBox()* function .

Thanks,
Amit


More information about the Wtr-general mailing list