Sign in to follow this  
Followers 0
mikeyr

script not working in IE8 but works in IE6

13 posts in this topic

I have a rather large app that has worked for over a year now and the system was recently upgraded to IE8. AIT ver. 3.3.0.0

What I am trying to do is a "send" to a field, it does not send under IE8. The field is a type="file"

<input name="FileUpload" id="FileUpload" type="file" />
and what I am doing is

$oForm2 = _IEFormGetObjByName($oIE, "_ctl0")
    $FileUp = _IEFormElementGetObjByName($oForm2, "FileUpload")
    _IEAction($FileUp, "focus")
    sleep(3000)  ;delay it for some reason sometimes it missed the C in C:\... path
    ;_IEFormElementSetValue ( $FileUp, $XMLFile ) ;not working for type=file field
    Send($XMLFile)
    Sleep(3000)

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

The send is not sending the filename so the submit fails, I don't know if it worked in IE7 since we went straight from 6 to 8, what I am missing. I added the "focus" today in a attempt to make it work it was not there before. The Sleeps are there because of some timing issues that occur occasionally, since this runs unattended every night, they are ok.

1. I think I may have to iosubmit a click to the field which causes browse file window to open and paste my text there and press "enter" but when i tried that it did not work first few times, still trying. Seems like the long way around however.

2. another option would be to make sure that the field has something in it before the submit button but I don't know how to get in the field since send and IEFormElementSetValue are not putting the data in.

By the way, I have quite a few AIT scripts that run nightly or weekly, and its still working so I am pretty sure the problem is with the type="file" and I CAN'T change the HTML is not written/maintained by me.

Share this post


Link to post
Share on other sites



Well, I have cut down my code quite a bit and re-written it but still get the problem, works under IE6 but not 8. Of course its also 2 different machines, my test machine has IE6 and the production machine has IE8 but I am assuming its IE8 since it worked fine until we upgraded IE.

I tried _IEDocInsertText but it seems to no longer be supported in AIT 3.3

So neither IEFormElementSetValue or send is working on this field, it works on other fields but not when type="file"

Looking desperately for any suggestions to try.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Well, I have cut down my code quite a bit and re-written it but still get the problem, works under IE6 but not 8. Of course its also 2 different machines, my test machine has IE6 and the production machine has IE8 but I am assuming its IE8 since it worked fine until we upgraded IE.

I tried _IEDocInsertText but it seems to no longer be supported in AIT 3.3

So neither IEFormElementSetValue or send is working on this field, it works on other fields but not when type="file"

Looking desperately for any suggestions to try.

If I recall correctly, Dale mentioned that as a security feature for IE. Try:

$oForm2 = _IEFormGetObjByName($oIE, "_ctl0")
$FileUp = _IEFormElementGetObjByName($oForm2, "FileUpload")
_IEAction($FileUp, "focus")
Sleep(3000) ;delay it for some reason sometimes it missed the C in C:\... path
$hIE = _IEPropertyGet($oIE, "HWND")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $XMLFile)
Sleep(3000)
$oSubmit = _IEGetObjByName($oIE, "ReadFileButton")

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks, that did not work but it gives me other options to look at if its a "feature", your solution did work on IE6 but not 8 so I know the code is good, I will poke around more.

Share this post


Link to post
Share on other sites

If I recall correctly, Dale mentioned that as a security feature for IE. Try:

Ok where do I find where this was posted ? I am getting desperate here, I may have to go go back to VB.NET to get this one done.

I am now doing a click on the field which opens the file browser window and that is not working either, what am I missing ?

;didnt work, leaving it in for now
;$hIE = _IEPropertyGet($oIE, "HWND")
;ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $XMLFile)

    _IEAction($FileUp, "click") ;open the file browse upload window
    ControlFocus ( "Choose file to Upload", "", "Edit1" ) ;give the input field focus
    $fName = _IEFormElementGetObjByName($oForm2, "Edit1")
    _IEAction($fName, "focus")
    Send($XMLFile)
    ControlClick ( "Choose file to Upload", "", "Button2"  )

Share this post


Link to post
Share on other sites

Will this work with the FireFox modules ? I only used IE because 2+ years ago when I wrote this app, the FireFox stuff was not available. Should I spend the time trying it in FireFox ? anyone know ?

(off to try it anyway)

Share this post


Link to post
Share on other sites

This is a change in browser security/behavior that cannot be overcome directly with any scripting. IE8 nor FF3.5 allow you to type into an input type=file field. As a result, I don't expect FF.au3 to offer a better alternative, but I don't have a lot of experience with it. Understand that the way you are trying to do this is exactly what they are trying to foil by changing how the fields work.

So, the only options I know of are automating the file selection dialog (I understand you are having trouble with that at the moment, but it can be made to work) or doing something to generate an HTTP POST with something like XMLHTTPRequest (I believe this can be done, but I have not dug into it at this point).

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

This is a change in browser security/behavior that cannot be overcome directly with any scripting. IE8 nor FF3.5 allow you to type into an input type=file field. As a result, I don't expect FF.au3 to offer a better alternative, but I don't have a lot of experience with it. Understand that the way you are trying to do this is exactly what they are trying to foil by changing how the fields work.

So, the only options I know of are automating the file selection dialog (I understand you are having trouble with that at the moment, but it can be made to work) or doing something to generate an HTTP POST with something like XMLHTTPRequest (I believe this can be done, but I have not dug into it at this point).

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

This is a change in browser security/behavior that cannot be overcome directly with any scripting. IE8 nor FF3.5 allow you to type into an input type=file field. As a result, I don't expect FF.au3 to offer a better alternative,

Perfect Thank You and I had no luck with FF either.

the only options I know of are automating the file selection dialog (I understand you are having trouble with that at the moment, but it can be made to work)

Still trying with no success BUT knowing it can be done will make me work on it until I figure it out :D

Thank You !

Share this post


Link to post
Share on other sites

Ok where do I find where this was posted ? I am getting desperate here, I may have to go go back to VB.NET to get this one done.

I am now doing a click on the field which opens the file browser window and that is not working either, what am I missing ?

;didnt work, leaving it in for now
;$hIE = _IEPropertyGet($oIE, "HWND")
;ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $XMLFile)

    _IEAction($FileUp, "click") ;open the file browse upload window
    ControlFocus ( "Choose file to Upload", "", "Edit1" ) ;give the input field focus
    $fName = _IEFormElementGetObjByName($oForm2, "Edit1")
    _IEAction($fName, "focus")
    Send($XMLFile)
    ControlClick ( "Choose file to Upload", "", "Button2"  )
I think you mixed _IE* functions in where you were dealing with a standard Windows GUI:
_IEAction($FileUp, "click") ;open the file browse upload window

; Now your're dealing with a regular window, not IE...
WinWait("Choose file to Upload", "")
$hUpload = WinGetHandle("Choose file to Upload", "")
ControlFocus($hUpload, "", "Edit1") ;give the input field focus
ControlSend($hUpload, "", "Edit1", $XMLFile)
ControlClick($hUpload, "", "Button2")

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

yes, you are correct I was trying to many things at once and did mix up my functions.

I still can't it to work in IE8, while in IE6 it correctly opens the file browser window chooses the file and clicks the button, in IE8 it opens the window but never gets the file name and waits.

I have requested we remove IE8 from the server and go back, that is a temporary fix at best since we will someday upgrade to WinServer2008 which has IE8, by then I will have re-written it in .NET or something else I hope.

Share this post


Link to post
Share on other sites

See this topic:

http://www.autoitscript.com/forum/index.php?showtopic=92907&st=0&gopid=731594&#entry731594

;-)

--

Elizeu

Share this post


Link to post
Share on other sites

THANK YOU !

I was trying it with getting window handles and object names and it was not working, I first looked at the example and said no way it wont work, too easy...fooled me, works great.

Thanks.

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