Sign in to follow this  
Followers 0
cpuobsessed

Can't get the DOM from a popup window

12 posts in this topic

I am trying to automate a ticketing system used at work. While changing information in a ticket a popup window is created, I'm trying to get the form from this window without any luck

CODE
_IEImgClick($mnToolbar,"Change Problem Severity","alt")

WinWaitActive("Change Problem Severity")

$sev_window=WinGetHandle("Change Problem Severity")

$sev_DOM=_IEAttach($sev_window,"hwnd")

ConsoleWrite(_IEPropertyGet($sev_DOM,"locationurl"))

$sev_iedoc = $sev_DOM.application

$sev_form = _IEFormGetObjByName($sev_iedoc, "frmSeverity")

;attach the pop-up window to an IE object

$sev_choosesev = _IEFormElementGetObjByName($sev_form,"severities")

$sev_addnote = _IEFormElementGetObjByName($sev_form,"txtNote")

_IEFormElementSetValue($sev_choosesev, $new_severity)

_IEFormElementSetValue($sev_addnote, $new_note)

_IEFormImageClick($sev_DOM,"OK","alt")

The _IEFormGetObjByName always fails and the resulting element function fail.

Any help would be appreciated.

Share this post


Link to post
Share on other sites



As a troubleshooting step, I suggest you add this after your _IEAttach so that you can validate the structure of that document:

ConsoleWrite(_IEDocReadHTML($sev_DOM) & @CR)

Make certain you can find the frmSeverity in the displayed source. Perhaps there are frames.

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

Share this post


Link to post
Share on other sites

I can't even get the HTML from the popup.

CODE
>Running:(3.2.2.0):E:\Program Files\AutoIt3\autoit3.exe "E:\work\problemmanger.au3"

0E:\PROGRA~1\AutoIt3\Include\IE.au3 (2064) : ==> The requested action with this object has failed.:

Return $o_object.document.body.innerHTML

Return $o_object.document^ ERROR

+>AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 59.674

Share this post


Link to post
Share on other sites

$sev_DOM=_IEAttach("Change Problem Severity","WindowTitle")
    ConsoleWrite(@error + @CRLF)

    $sev_iedoc = _IEDocGetObj($sev_DOM)
        ConsoleWrite(_IEDocReadHTML($sev_DOM) + @CRLF)
    $sev_form = _IEFormGetObjByName($sev_DOM, "frmSeverity")
    
    ;attach the pop-up window to an IE object
        
    $sev_choosesev = _IEFormElementGetObjByName($sev_DOM,"severities")
    $sev_addnote = _IEFormElementGetObjByName($sev_DOM,"txtNote")

Returns this:

CODE
IE.au3 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidObjectType

--> IE.au3 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidObjectType

--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

--> IE.au3 Warning from function _IEFormImageClick, $_IEStatus_NoMatch

+>AutoIT3.exe ended.rc:0

Why am I not getting an IE object?

Share this post


Link to post
Share on other sites

This code fails:

WinWaitActive("Change Problem Severity")
    $sev_window=WinGetHandle("Change Problem Severity") 
    ConsoleWrite($sev_window + @CRLF)
    
    $sev_DOM=_IEAttach($sev_window,"hwnd")
    ConsoleWrite($sev_DOM + @CRLF)
    
    $sev_iedoc = _IEDocGetObj($sev_DOM)
    ConsoleWrite(_IEDocReadHTML($sev_iedoc) + @CRLF)
    $sev_form = _IEFormGetObjByName($sev_iedoc, "frmSeverity")
    
    ;attach the pop-up window to an IE object
        
    $sev_choosesev = _IEFormElementGetObjByName($sev_DOM,"severities")
    $sev_addnote = _IEFormElementGetObjByName($sev_DOM,"txtNote")

With this message:

CODE
>Running:(3.2.2.0):E:\Program Files\AutoIt3\autoit3.exe "E:\work\problemmanger.au3"

0x001D0D02E:\PROGRA~1\AutoIt3\Include\IE.au3 (2165) : ==> The requested action with this object has failed.:

Return $o_object.document.documentElement.outerHTML

Return $o_object.document^ ERROR

Share this post


Link to post
Share on other sites

Am I not using _IEAttach correctly?

Share this post


Link to post
Share on other sites

The console messages don't match your code.

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

Share this post


Link to post
Share on other sites

The console messages don't match your code.

Dale

That is exactly what happens, it isn't getting any object it can use from the IEAttach, no HTML is put out, no forms, nothing.

The $sev_DOM contains nothing that can be used.

Share this post


Link to post
Share on other sites

Again, the console messages don't match your code.

What does this" popup" look like? You may need to use the "popup" parameter with _IEAttach

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

Share this post


Link to post
Share on other sites

Now the script crashes:

WinWaitActive("ManageNow : R1 Problem Management - Change Problem Severity - Windows Internet Explorer")
    $sev_window=WinGetHandle("ManageNow : R1 Problem Management - Change Problem Severity - Windows Internet Explorer") 
    ConsoleWrite($sev_window + @CRLF)
    
    $sev_DOM=_IEAttach($sev_window,"DialogBox")
    ConsoleWrite($sev_DOM + @CRLF)
    
    $sev_iedoc = _IEDocGetObj($sev_DOM)
    ConsoleWrite(_IEDocReadHTML($sev_iedoc) + @CRLF)
    $sev_form = _IEFormGetObjByName($sev_iedoc, "frmSeverity")

gives this on the console:

CODE
>"E:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "E:\work\problemmanger.au3" /autoit3dir "E:\Program Files\AutoIt3" /UserParams

+> Starting AutoIt3Wrapper v.1.7.3

>Running AU3Check (1.54.6.0) params: from:E:\Program Files\AutoIt3

+>AU3Check ended.rc:0

>Running:(3.2.2.0):E:\Program Files\AutoIt3\autoit3.exe "E:\work\problemmanger.au3"

0x00230CACE:\PROGRA~1\AutoIt3\Include\IE.au3 (290) : ==> Unknown option or bad parameter specified.:

Local $iWinTitleMatchMode = Opt("WinTitleMatchMode")

«|ë|

+>AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 43.857

Share this post


Link to post
Share on other sites

Sorry, forgot, that is an AutoIt regression in 3.2.2.0 fixed in 3.2.3.0 - see here

Since that is not released please edit IE.au3 and mod line 290 with the word-around.

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Now I've got a but report, this code:

WinWaitActive("ManageNow : R1 Problem Management - Change Problem Severity - Windows Internet Explorer")
    $sev_window=WinGetHandle("ManageNow : R1 Problem Management - Change Problem Severity - Windows Internet Explorer") 
    ConsoleWrite($sev_window + @CRLF)
    
    $sev_DOM=_IEAttach("ManageNow : R1 Problem Management - Change Problem Severity","WindowTitle")
    ConsoleWrite($sev_DOM + @CRLF)
    MsgBox(0,"change sev location",_IEPropertyGet($sev_DOM,"locationurl") + @CRLF)
    
    ;$sev_iedoc = _IEDocGetObj($sev_DOM)
    ConsoleWrite(_IEDocReadHTML($sev_DOM) + @CRLF)
    $sev_form = _IEFormGetObjByName($sev_DOM, "frmSeverity")
    
    ;attach the pop-up window to an IE object
        
    $sev_choosesev = _IEFormElementGetObjByName($sev_DOM,"severities")
    $sev_addnote = _IEFormElementGetObjByName($sev_DOM,"txtNote")

Causes AutoIT to crash:

CODE
>"E:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "E:\work\problemmanger.au3" /autoit3dir "E:\Program Files\AutoIt3" /UserParams

+> Starting AutoIt3Wrapper v.1.7.3

>Running AU3Check (1.54.6.0) params: from:E:\Program Files\AutoIt3

+>AU3Check ended.rc:0

>Running:(3.2.2.0):E:\Program Files\AutoIt3\autoit3.exe "E:\work\problemmanger.au3"

!>AutoIT3.exe ended.rc:-1073741819

>Exit code: -1073741819 Time: 54.747

I have tried a number of different options for _IEAttach, "WindowTitle" caused the crash. "dialogbox" does not return anything for "locationurl" in _IEPropertyGet.

Edited by cpuobsessed

Share this post


Link to post
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
Sign in to follow this  
Followers 0