OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | clif List | April 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[clif] RE: Re: httpInjector save form fields??


Title: Vot

Hello,

 

Thanks for your answer. I’m trying what you wrote but can’t  

get it working. L

 

I attached my test scenario in this email.

 

I have no problem creating a new VAR and printing it on the screen

While running the test. But when I want to “save” the GET website.

No results are made.

 

I tried a lot of options non of them seems to work.

 

${string1:}

${string1:default}

 

Any idea what I doing wrong???

 

Thanks.


Greetings,

Marc van Dam

 

 

 

 

 

 

 

Van: Bruno Dillenseger [mailto:bruno.dillenseger@xxxxxxxxxxxxxxxxxx]
Verzonden: vrijdag 29 februari 2008 19:35
Aan: Marc van Dam_new
CC: clif@xxxxxxx
Onderwerp: [clif] Re: httpInjector save form fields??

 

Bruno Dillenseger wrote:

Marc van Dam_new wrote:

Question: Is it possible in HttpInjector to get variables
from specific (hidden) form content??

For example: I need to do 1x GET 1x POST command.

In the GET command a website is received with for example following form:

<form action="" method="get" name="mytest">

Username: <input name="username" type="text">
Password: <input type="password" name="textfield">

<input name="MYFIELD1" type="hidden" value="CHANGING CODE">

<input type="submit" name="Submit" value="Submit">
</form>

I need a variable to store "value" of MYFIELD1. So I can later
re-use it when I use POST.
Is this in any way possible with Clif??
 

In my understanding, what you want to do is to extract some value from the received HTML page and to insert this value in your next request.
The general schema to do this is to put the result of your GET in a variable (option in the GET parameters page), then to set a StringHandler plug-in's value with this variable using the ${httpPluginId:my_variable_for_last_loaded_page}, then to use this StringHandler to extract the value, for instance based on a regular _expression_. An alternative is to implement this parsing feature in an HTML-specific way directly in the HttpInjector. Finally, you send your POST method inserting the extracted value at the right place with a variable _expression_ ${parserId:value}

The thing is both ways are possible but not implemented yet.

If you are a Java developer, it won't take long for you to extend the StringHandler or the HttpInjector ISAC plug-in so that it can parse the last loaded HTML page and extract the value. This would be typically done by wrapping Java's StringBuilder API and the regular _expression_ supported by package java.util.regex, or the included HtmlParser library. It would be an interesting contribution. If you are not a Java developer, then a request for feature should be created in the Forge to induce someone in the community to commit such an enhancement, which is definitely something we need to have in CLIF.

Good news for you (and the CLIF community)!
I implemented a pattern matching and capturing feature in the StringHandler plug-in.
It makes use of Java5 java.util.regex (see http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html).

In your case, you may use the following pattern: <input name="MYFIELD1" type="hidden" value="([^\"]*)">
And then match and capture at level 1 (level 0 would match with the whole pattern, while level 1 matches with the region delimited with parenthesis () which is what we want). There is a sample scenario available in the "test" directory along with the source code of the StringHandler plug-in.
It is lightly tested yet, but you may enjoy ;-)

Best regards,

-- Bruno.

Attachment: scenario-adv.xis
Description: Binary data



<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.