Sign in to follow this  
Followers 0
psps

IE -Determine Form and Field when they have the same names

4 posts in this topic

#1 ·  Posted (edited)

Hi -

Attempting to "graduate" from my "send keys, wait and hope" use of AutoIT. I was doing great filling in forms and submitting until I got to the Import/Export page where I need to fill in a file name on a page with several file name fields. This is where I used to {tab} in a loop about 50 or 55 times depending on which upload I want to process to get to the correct field and then "send" the file name, {tab} to the button and press {enter} or {space}. Problem now is that the forms all named "form1" and the fields are named "file1".

I have been all over the place even installed the debugbar for IE. Makes it much easier to see the forms - but does change the fact that there are 16 of them all with the same name. The actions for the forms are unique - but there's an on the fly (changes) security token embedded in the actions - so even if I could use action to distinguish the forms - I can't easily predict it.

Is there a way I'm not seeing to indicate say the 6th "file1" field and then _IEFormElementSetValue it followed but a submit? I'm likely to hit the same problem with the download buttons also having the same names.

Thanks in advance for any pointers.

-PSPS

Two sample form sections....

<FORM id=form1 encType=multipart/form-data method=post name=form1 action=import_prod.asp?table=Products&amp;hdnSecurityToken=xxxxxxxxxxxxxxxxxxxxxx target=_blank><TBODY>

<TR align=middle>

<TD class=cell width="2%"><A onmouseover="ajax_showTooltip_help('help.asp?help_file=imp_Products.asp',this);return false" onmouseout=ajax_hideTooltip() href="#"><IMG border=0 src="templates/images/help_icon.gif"></A> </TD>

<TD class=fieldname width="23%" align=left>Products </TD>

<TD class=cell vAlign=top width="50%" align=left>Insert and Update Products&nbsp;&nbsp;<A href="http://www.aaaaa.com/downloads/import_files/products.csv" target=_blank>Sample File</A><BR><INPUT id=path value=../assets/exports/ type=hidden name=path> <INPUT id=file1 class=txtBoxStyle2 size=40 type=file name=file1> </TD>

<TD class=fieldname vAlign=center width="25%" align=right><BUTTON id=Button3 class="scalable gray" onclick=this.form.submit(); type=button value="Export Data"><SPAN>Import Data </SPAN></BUTTON> </TD></TR></FORM>

--------

<FORM id=form1 encType=multipart/form-data method=post name=form1 action=import_prod.asp?table=Categories&amp;hdnSecurityToken=xxxxxxxxxxxxxxxxxxxxxx target=_blank><TR align=middle>

<TD class=cell width="2%"><A onmouseover="ajax_showTooltip_help('help.asp?help_file=imp_Categories.asp',this);return false" onmouseout=ajax_hideTooltip() href="#"><IMG border=0 src="templates/images/help_icon.gif"></A> </TD>

<TD class=fieldname width="23%" align=left>Categories </TD>

<TD class=cell vAlign=top width="50%" align=left>Import a list of Categories&nbsp;&nbsp;<A href="http://www.aaaaa.com/downloads/import_files/category_import_model.xls" target=_blank>Sample File</A><BR><INPUT id=path value=../assets/exports/ type=hidden name=path> <INPUT id=file1 class=txtBoxStyle2 size=40 type=file name=file1> </TD>

<TD class=fieldname vAlign=center width="25%" align=right><BUTTON id=Button3 class="scalable gray" onclick=this.form.submit(); type=button value="Export Data"><SPAN>Import Data </SPAN></BUTTON> </TD></TR></FORM>

Edited by psps

Share this post


Link to post
Share on other sites



psps,

You will need to get the forms and elements by index and can be found in the help file _IEFormGetCollection and _IEFormElementGetCollection.

jfcby


Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites

psps,

You will need to get the forms and elements by index and can be found in the help file _IEFormGetCollection and _IEFormElementGetCollection.

jfcby

Thanks that helped. Through some trial and error and using some loops other folks had written. I figured out the correct form index. It was still killing me that I could not set the field value. By extreme luck I noticed in an example that fields of File Name type can not be set with setvalue and saw how to set the focus then just send the darn keys after all.

But.... this way I can be sure that I'm acually on the correct field.

On to the next challenge of dealing with the the new browser windows that comes up when I submit. Just need to wait for it to completely load then click on a text link that processes the uploaded file. Not sure if this is considered a child browser window or ? The action button requests a _blank window.

Still a bit fuzzy on IELoad wait or testing for "done" in the status line.

-psps

Share this post


Link to post
Share on other sites

Thanks that helped. Through some trial and error and using some loops other folks had written. I figured out the correct form index. It was still killing me that I could not set the field value. By extreme luck I noticed in an example that fields of File Name type can not be set with setvalue and saw how to set the focus then just send the darn keys after all.

But.... this way I can be sure that I'm acually on the correct field.

On to the next challenge of dealing with the the new browser windows that comes up when I submit. Just need to wait for it to completely load then click on a text link that processes the uploaded file. Not sure if this is considered a child browser window or ? The action button requests a _blank window.

Still a bit fuzzy on IELoad wait or testing for "done" in the status line.

-psps

UPDATE - really close!

So I managed to Attach to and control the browser window that comes up as soon as you issue the _IEsubmit(). What I'm not quite sure about is the proper way to "wait" for the new window to open and display it's contents. Right now I threw in a sleep(20000) before attempting to Attach. Depending on the file size, connection... etc - that doesn't seem like the best way (trying to break old bad techniques where I would always just use huge sleep commands).

Do you just need to create a while loop the enumerate windows cycling through them until it is available and then attach then _IELoadWait against the new window? There are two delays in the process trying to account for. First is the delay while the file uploads, second is how long the next window takes to fully load.

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