Jump to content

Java Script popup's


 Share

Recommended Posts

Hi All,

I have use the following commands to handle the Java Popup on the .Net browser based application.

1. Winkill("Windows Internet Explorer")

2. ControlClick

3. ControlFocus

But I was unable to handle the same.

My motive is to press 'OK' on the Java script.

Can anybody help me in the same.

Thanks in Advance.

Mr. Singh.

Link to comment
Share on other sites

I think this is what you want:

Opt("WinTitleMatchMode", 3) ;Set's the option so that the title must match exactly
WinWait( "Windows Internet Explorer", "")
ControlClick( "Windows Internet Explorer", "OK", 1 )
Some pop-ups are Win32 windows with standard windows controls -- your solution will work there.

Others are HTML pop-ups and you'll either need to activate the window and then send appropriate Tab and Enter keys or use _IEAttach with the embedded option and then use IE.au3 commands to manipulate it.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

First of all thanks for the reply....

Yes its the type of Alert pop up which is used in the web based application with the help of Java.

Below is the script to handle the same -

-----------------------------------------------------------------------------------------------------

#include <IE.au3>

#include <file.au3>

dim $aRecords

If Not _FileReadToArray("C:\Documents and Settings\shekhar.sherwal\Desktop\AutoIT\password.txt",$aRecords)Then

_FileWriteToLine("C:\log.txt", 1, "File is not present", 0)

MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

Exit

EndIf

; get pointers to the login form and username and password fields

$oIE = _IECreate("<local application name>")

$o_form = _IEFormGetObjByName($oIE, "frmLogin")

$o_login = _IEFormElementGetObjByName($o_form, "txtuid")

$o_password = _IEFormElementGetObjByName($o_form, "txtpwd")

; Set field values and submit the form

_IEFormElementSetValue($o_login, $aRecords[1])

_IEFormElementSetValue($o_password, $aRecords[2])

Sleep(2000)

$oSubmit = _IEGetObjByName ($oIE, "btn_login")

_IEAction ($oSubmit, "click")

Sleep(6000)

_IENavigate ($oIE, "https://www.clcsdqt.com/Cemex-DQT/User/WizSetup1.aspx")

$o_form1 = _IEFormGetObjByName ($oIE, "aspnetForm")

$o_logout = _IEGetObjByName($oIE, "ctl00$NavigationBar$imgBtnLogout")

_IEAction ($o_logout, "click")

Opt("WinTitleMatchMode", 3) ;Set's the option so that the title must match exactly

WinWait("Windows Internet Explorer", "")

WinActivate("Windows Internet Explorer", "")

if WinActivate("Windows Internet Explorer") Then

MsgBox(4096, "Test", "This box will time out in 10 seconds", 10)

EndIf

ControlClick("Windows Internet Explorer", "OK", 1 )

Exit

--------------------------------------------------------------------------------

The above script work fine till "_IEAction ($o_logout, "click")"

This command open the popup for confirmation.

But I am unable to handle this popup

Below is the part of the source code of the form where this popup occurs -

---------------------------------------

<td id="ctl00_NavigationBar_tdLogout" align="right" valign="top" style="padding-top: 0px; padding-right: 0px; height: 57px;">

<input type="image" name="ctl00$NavigationBar$imgBtnLogout" id="ctl00_NavigationBar_imgBtnLogout" alt="Logout" border="0" src="../Images/Images_US/logout.jpeg" onclick="java script:return confirm('Are you sure you want to logout?');" style="border-width:0px;" />&nbsp;</td>

</tr>

<tr valign="bottom" width="100%">

<td align="right" valign="baseline" colspan="7">

<table id="ctl00_NavigationBar_tblMiddleBand" border="0" cellspacing="0" cellpadding="0">

<tr id="ctl00_NavigationBar_trMainMenu" valign="bottom">

<td id="ctl00_NavigationBar_tdedge" align="right" valign="bottom" style="height: 100%; padding-left: 0px;

padding-right: 0px">

<img id="ctl00_NavigationBar_imgEdge" class="navigationBg" border="0" src="../images/grayImg.gif" align="right" style="border-width:0px;" /></td>

<td id="ctl00_NavigationBar_tdIntroDuction" class="navigationBg" style="padding-right: 10px">

<a onclick="java script:return confirm('Any unsaved selections or changes will be lost. Do you wish to continue?');" id="ctl00_NavigationBar_lnkIntroduction" class="navigationBg" href="java script:__doPostBack('ctl00$NavigationBar$lnkIntroduction','')">Introduction & User Guide</a>

</td>

<td id="ctl00_NavigationBar_tdReportBuilder" class="navigationActiveBg" style="padding-right: 10px; padding-left: 10px;">

<a id="ctl00_NavigationBar_lnkRptBuilder" class="navigationBg" href="java script:__doPostBack('ctl00$NavigationBar$lnkRptBuilder','')">Report Builder</a>

</td>

<td width="450" class="navigationBg">

&nbsp;</td>

</tr>

</table>

--------------------

I am very new to the autoit. And I got stuck with these popup things.

Thanks in Advance...

Singh

Link to comment
Share on other sites

Actually, assuming you are talking about the PopUp generated by the 'confirm' statement, it is in fact a Win32 popup window and can be controlled with Gabbard's approach.

You can use the following HTML to test:

<HTML>
<BODY>
     <input type=button value='Test' onclick="confirm('Yo');">
</BODY>
</HTML>

Use the AutoIt Window Info tool to get details on the controls.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • 1 month later...

The following example was created to try to click on a 'confirm' statement button:

Opt("WinTitleMatchMode", 3) ;Sets the option so that the title must match exactly
#include <IE.au3>
$oIE = _IECreate()
$sHTML = "<HTML>" & @CRLF
$sHTML &= "<BODY>" & @CRLF
$sHTML &= "     <input type=button value='Test' onclick=""confirm('Yo');"">" & @CRLF
$sHTML &= "</BODY>" & @CRLF
$sHTML &= "</HTML>"
_IEDocWriteHTML($oIE, $sHTML)
$oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
    _IEAction($oInput, "Click")
    WinWait( "Windows Internet Explorer", "")
    ControlClick( "Windows Internet Explorer", "OK", 1 )
Next

It does not seem to find the window. Here is the window info:

>>>> Window <<<<

Title: Windows Internet Explorer

Class: #32770

Position: 584, 322

Size: 207, 126

Style: 0x94C801C5

ExStyle: 0x00010101

>>>> Control <<<<

Class: Button

Instance: 1

ID: 1

Text: OK

Position: 610, 411

Size: 75, 23

ControlClick Coords: 36, 11

Style: 0x50030001

ExStyle: 0x00000004

>>>> Mouse <<<<

Position: 646, 422

Cursor ID: 2

Color: 0x6F0073

>>>> StatusBar <<<<

>>>> Visible Text <<<<

OK

Cancel

Yo

>>>> Hidden Text <<<<

Did/can anyone get this to work?
Link to comment
Share on other sites

This is complicated, but has been discussed several times before... your click gets stuck waiting for the confirm to close before returning control to AutoIt. The following will work around this:

#include <IE.au3>
$oIE = _IECreate()
$sHTML = "<HTML>" & @CRLF
$sHTML &= "<BODY>" & @CRLF
$sHTML &= "     <input type=button value='Test' onclick=""confirm('Yo');"">" & @CRLF
$sHTML &= "</BODY>" & @CRLF
$sHTML &= "</HTML>"
_IEDocWriteHTML($oIE, $sHTML)
$oInputs = _IETagNameGetCollection($oIE, "input")
$hwnd = _IEPropertyGet($oIE, "hwnd")
For $oInput In $oInputs
    _IEAction($oInput, "focus")
    ControlSend($hwnd, "", "[class:Internet Explorer_Server; instance:1]", "{Enter}")
    WinWait( "Windows Internet Explorer", "")
    ControlClick( "Windows Internet Explorer", "OK", 1 )
Next

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...