Jump to content
Sign in to follow this  
ohaya

Backporting to 3.3.61 - Problem with setting focus on form element field

Recommended Posts

Hi,

I have some code that I originally developed and tested using the AutoIT downloaded from the AutoIT website (3.3.14.x), which  uses the _IE functions to find a field/element within a web page, set focus to that field, and then send some data to that field.  That was working with AutoIT and the _IE module that came with 3.3.14.

However, I have been asked to get this code working with an older version of AutoIT (and _IE functions), 3.3.6.1 (because that is the version that comes with a COTS product we are working with.

I have been able to get it mostly working, but I am having problem with setting the focus on the element.

Here's a snippet of the code that I think is having the problem:

; $PARMtargetFormElementNumber has the element number (0-based)
Local $oElement = _IEFormElementGetCollection($oForm, Number($PARMtargetFormElementNumber))

if (@error > 0) Then
    LogWrite($BANNER & "Couldn't get the element, error=[" & @error & "]")
    _IEAction($oForm, "focus")
Else
    LogWrite($BANNER & "GOT the element (name=[" & $oElement.name & "] - will set FOCUS HERE, error from _IEFormElementGetCollection()=[" & @error & "] $oElement.name=[" & $oElement.name & "] & id=[" & $oElement.id & "] & type=[" & $oElement.type & "]")
    _IEAction($oElement, "focus")
    LogWrite($BANNER & "Did _IEAction 'focus' on the form element, error from _IEAction()=[" & @error & "]")
EndIf

That code should be positioning the cursor on the username field and then I send the username data, but instead of the cursor being positioned to the username field, the cursor appears to be set to the browser's address textbox.

Did the _IE functions that I used above (e.g., the _IEAction(), etc.) function differently in the older 3.3.6.1 AutoIT and _IE functions?  If so, can anyone tell me what I need to change to get it working with the AutoIT and _IE functions for the 3.3.6.1 version?

 

Thanks,

Jim

Share this post


Link to post
Share on other sites

You should look inside the code for the functions that you're using, comparing the 3.3.6.1 code with what's in the UDFs for the current version and see what's different. If there's no difference in the functions, then there's a change to AutoIt's exe that is probably causing the issue.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
32 minutes ago, Danp2 said:

As seen here, that's a very old version of Autoit. You can look through that list to see what has changed, but I truly don't understand the logic of trying to rewrite the code to work with such an old version.

Hi,

Yes, it is REALLY unfortunate.  Believe me, I pushed back, but I think we have to do it because, logistically, the 3.3.6.1 version is what came with another product that we are using, and so we have to go with that :(....

Share this post


Link to post
Share on other sites
6 minutes ago, BrewManNH said:

You should look inside the code for the functions that you're using, comparing the 3.3.6.1 code with what's in the UDFs for the current version and see what's different. If there's no difference in the functions, then there's a change to AutoIt's exe that is probably causing the issue.

Hi,

I kept the "new" instance (actually, I am doing the backporting on a new VM, and I kept the old VM for reference), so which files would I compare?  Is it only the IE.au3?

Share this post


Link to post
Share on other sites

Look at whatever functions you're using that aren't working the same, compare the code in them from both versions, and see what might have changed. Are both scripts being run against the same version of IE?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BrewManNH,

Yes, both are working against the same version of IE.

I compared the code in the two IE.au3 files, for both handling 'focus' and for 'click', and that code essentially does object.Focus() and object.Click(), respectively.

Share this post


Link to post
Share on other sites

Hi,

I should've mentioned some additional information:  The webpage that I am processing is from a small IIS website with ASP.NET authentication that simulates one of the actual target sites, that I put together so that I could test the AutoIT code.

I have several similar IIS/ASP.net websites.

One of them has a simple form with 2 fields, for username and password.  I have AutoIt code that works with this simpler form, even with the older 3.3.6.1 AutoIt.

The website/webpage I am having problems with is slightly different than the simple form one, in that when the page is initially accessed, it shows just a link.  Then, when that link is clicked, a form appears.  This is done with <DIV>s and a small bit of javascript (to unhide the <DIV> that has the form).

So for this website/page, I have to do the following using AutoIt:

  • Find the link
  • Click the link
  • Find the form
  • Find the username element in the form
  • Send the username, tab, then send the password, then click a button

I have all of the above working with the newer AutoIt, but, with the older 3.3.6.1 AutoIt, while my code can find and click the link, AND find the form and the username element, it just cannot, for some reason, put the focus/cursor into the username field :(...

The reason I am mentioning all of this is that I guess I don't understand why, with the simpler form, I can set the focus, even with the older 3.3.6.1 AutoIt, but not with the form with the click-link??  I mean I am using the same older AutoIt for both the simpler webpage and for the more complex webpage, so I am using the same AutoIt methods for finding the form and the element, and for setting the focus, so why is this failing?

Sorry for the long post !

Jim

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...