Jump to content
WAPT Forum
Sign in to follow this  
Guest vince

Add Post parameters dynamically

Recommended Posts

Guest vince

Hi All

 

I'm entirely new to wapt.

 

I want to add post parameters to a wapt request dynamically based on the response from previous request.

 

How is it possible?

 

Thanks in advance

 

Vince

Share this post


Link to post
Share on other sites

Hi All

 

I'm entirely new to wapt.

 

I want to add post parameters to a wapt request dynamically based on the response from previous request.

 

How is it possible?

 

Thanks in advance

 

Vince

 

Do you want to add a post parameter with a new name or modify a value of some old one?

Share this post


Link to post
Share on other sites
Guest vince

Hi

 

I will explain a scenario.

I have a sales order page and it got a grid. According to the user entry the grid may contain any number of items/rows. Say first time it may have 10 items, second time it may have 20 items. So i need to parameterize all the parameters associated with this grid. How can I do that?

 

Thanks

Vince

Share this post


Link to post
Share on other sites
Guest vince

As an Example consider a Sales Order or and Invoice. The NUmber of Items is most of the times DYNAMIC. It could be 5 Itesm one time and 10, 15, etc... items in other cases. The Name Value pairs handling these will be usually numberred sequentially like:

 

1. Name = ItemName01, Value = ItemValue01

2. Name = ItemName02, Value = ItemValue02

3. Name = ItemName03, Value = ItemValue03

4. Name = ItemName04, Value = ItemValue04

5. Name = ItemName05, Value = ItemValue05

6. Name = ItemName06, Value = ItemValue06

 

 

 

n. Name = ItemName0n, Value = ItemValue0n

 

Is tehre any means by which the Name value pairs can be formed dynamically in realtime? Java Sctipt could be one solution, how could we access teh DOM of the previous request?

 

 

regards,

Vince

Share this post


Link to post
Share on other sites

You can create POST request with POST parameters type "Text" and use a variable in request body.

Before POST request you should create JavaScript operator and initialize a value of the variable in JavaScript.

Share this post


Link to post
Share on other sites
Guest vince

Hi Sergei

 

I tried with "POST Parameters Type" as "Text" in "POST Parameters" tab without using any javascript, just harcoded POST parameter values. But it is not working!!

Share this post


Link to post
Share on other sites

Hi Sergei

 

I tried with "POST Parameters Type" as "Text" in "POST Parameters" tab without using any javascript, just harcoded POST parameter values. But it is not working!!

 

You need to use JavaScript operator to generate POST parameters.

Share this post


Link to post
Share on other sites
Guest vince

Hi Sergei

 

Thanks a lot for your help. Really appreciate it.

 

Can you please provide a sample example?

 

Vince

Share this post


Link to post
Share on other sites

I have a similar scenario where my first page itself is a request that contains numbers that randomly change. I used your example file and i initialized the javascript before page1 and gave a value1. I declared the value1 in initial variables but when i verify it, the script still fails saying value1 is not found. Can you please help? I attached screenshot of my issue if that helps.

post-20286-0-60675000-1339535929.png

post-20286-0-38860900-1339535937.png

post-20286-0-23571300-1339535944.png

Share this post


Link to post
Share on other sites

If you want to use WAPT variable from JavaScript you should use method:

context.variable("var_name") - gets/sets the value of the "var_name" variable;

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...