Sign in to follow this  
Followers 0
Debbie

Feed a Web application

10 posts in this topic

Hi

First at all, I apologize if my english is not perfect as it is not my native language. Feel free to ask me to reformulate a sentence if necessary.

I try to drive a Web application (PHP) running on firefox to input data I own in a file.

I cannot modify the web application. I use autoit and FF.au3 to send my data.

The web application source page have (among all the source code), this optionmenu :

<select name="parent">

<option value="1">Home</option>

<option value="72">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A</option>

<option value="73">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B</option>

<option value="74">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C</option>

</select>

I do not succeed to fill this optionmenu :-(

I tried _FFFormOptionselect but failed to find the correct parameters. So I tried _FFSetValueByName which seems to work fine ... but I need to know the values (1, 72, 73, 74). Theses values are generated by the web application, and I do not know them (statically).

What I know are the labels as seen by the end user(Home, A, B, C).

Is there any mean to select the item knowing the label ?

Thanks a lot

Debbie

Share this post


Link to post
Share on other sites



If you have only have one form on this web application then the parameters for _FFFormOptionselect are e.g.:

Select by value:

_FFFormOptionselect("parent", "name", "72", "value")

Select by "label" (the text you can see):

_FFFormOptionselect("parent", "name", "A", "text")

Share this post


Link to post
Share on other sites

If you have only have one form on this web application then the parameters for _FFFormOptionselect are e.g.:

Select by "label" (the text you can see):

_FFFormOptionselect("parent", "name", "A", "text")

Hi

There is multiple form. The one containg the optionmenu is declared as :

<form action="myaddress/index.php?tab=AdminCatalog&submitAddcategory=1&token=xxxx" method="post" enctype="multipart/form-data">

Does it change something ?

BTW, To make my request more simple, "A" is not "A" but "&nbsp;&nbsp;A". I presume that

the code should be : _FFFormOptionselect("parent", "name", car(160) & car 160) & "A", "text"), not ?

Thanks

Debbie

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi

There is multiple form. The one containg the optionmenu is declared as :

<form action="myaddress/index.php?tab=AdminCatalog&submitAddcategory=1&token=xxxx" method="post" enctype="multipart/form-data">

Does it change something ?

BTW, To make my request more simple, "A" is not "A" but "&nbsp;&nbsp;A". I presume that

the code should be : _FFFormOptionselect("parent", "name", car(160) & car 160) & "A", "text"), not ?

Thanks

Debbie

If you have multiple forms without any names or ids, then you must use the form-index (0-n) e.g. second form:

_FFFormOptionselect("parent", "name", "A", "text", 1)

to find out the index, you can use my tool:

FF-Page-Analyzer

The text (name, id...) is always searched by substring, so it makes in this case no difference between:

_FFFormOptionselect("parent", "name", "A", "text")
;and
_FFFormOptionselect("parent", "name", "&nbsp;&nbsp;A", "text")
Edited by Stilgar

Share this post


Link to post
Share on other sites

If you have multiple forms without any names or ids, then you must use the form-index (0-n) e.g. second form:

_FFFormOptionselect("parent", "name", "A", "text", 1)

[...]

Thanks, it works fine ! I have gone one step further.

In some case, it appears that the label is sometimes duplicated as follow :

<select name="id_parent">
  <option value="1">Home</option>
      <option value="139">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 1</option>
      <option value="141">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AAA</option>
      <option value="142">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BBB</option>
      <option value="143">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CCC</option>
  <option value="140">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cas2 2</option>
      <option value="144">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AAA</option>
      <option value="145">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BBB</option>
      <option value="146">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CCC</option>
</select>

I tried to select "Case 1" then "BBB" to select the first one, and "Case 2" then "BBB" to select the second one. Unfortunatly it was a too tricky idea :-)

Is there a way to do that ?

Else, is there a function I may call to get the source code of the loaded web page ? With regular expression I may probably find the "option value" and so, make it simple...

Thanks

Debbie

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Is there anything static like the index? Or has the list always another size?

Then you can select it by index.

Or you can do the following:

Search all the values of all options with the text "AAA":

$aArray = _FFXPath("//select[@name='id_parent']//option[contains(.,'AAA')]", "value",6)
_ArrayDisplay($aArray) ; just for example

then you can select the option with _FFFormOptionselect by value.

[EDIT]

Other example:

; at first search the index of "Case 2"
$iIndexCase2 = _FFXPath("//select[@name='id_parent']//option[contains(.,'Case 2')]", "index",9)
; and then select the option with "AAA" after the index of "Case 2"
_FFXPath("//select[@name='id_parent']//option[position() > " & $iIndexCase2 & " and contains(.,'AAA')]", "selected=true",9)
Edited by Stilgar

Share this post


Link to post
Share on other sites

Is there anything static like the index? Or has the list always another size?

Then you can select it by index.

In fact, this part of the web application build this list. Each time I enter a data, the list increase. I can enter the name (and few other data), but the value is computed by the application (probably something to do with an auto increment).

I have the same problem (so will use the same solution :-) ) for part of the software builting others lists.

Or you can do the following:

Search all the values of all options with the text "AAA":

$aArray = _FFXPath("//select[@name='id_parent']//option[contains(.,'AAA')]", "value",6)
_ArrayDisplay($aArray) ; just for example

then you can select the option with _FFFormOptionselect by value.

The return value looks like a hexa data or something like that. Should I StringFormat it to a string ?

Other example:

; at first search the index of "Case 2"
$iIndexCase2 = _FFXPath("//select[@name='id_parent']//option[contains(.,'Case 2')]", "index",9)
; and then select the option with "AAA" after the index of "Case 2"
_FFXPath("//select[@name='id_parent']//option[position() > " & $iIndexCase2 & " and contains(.,'AAA')]", "selected=true",9)

Unfortunatly it points to the first AAA (case 1)

No way to get the current source code of the web page ?

Thanks

Debbie

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The return value looks like a hexa data or something like that. Should I StringFormat it to a string ?

Unfortunatly it points to the first AAA (case 1)

No way to get the current source code of the web page ?

Strange - I've tried it with your HTML-code and it works. No hex data or so and the second AAA is selected.

If you start it from your editor - can you show me the output from editor-console, please?

Source-Code: _FFReadHTML or (much faster) _InetGetSource

Edited by Stilgar

Share this post


Link to post
Share on other sites

Strange - I've tried it with your HTML-code and it works. No hex data or so and the second AAA is selected.

If you start it from your editor - can you show me the output from editor-console, please?

Source-Code: _FFReadHTML or (much faster) _InetGetSource

May I send you the source web page, just to test on your computer with the same example ?

Thanks

Share this post


Link to post
Share on other sites

May I send you the source web page, just to test on your computer with the same example ?

Thanks

Yes, just send it.

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