Auto Correlation of Dynamic Forms

As described in Generating a Web Script, Eggplant Performance provides a generation option to automatically correlate forms. This enables the automatic correlation of POST and query data at runtime that would otherwise have to be done manually. This section describes the dynamic form handling mechanism. See Virtual User Parameterization Process for more on correlation.

Note: Auto correlation works with forms that change both in content and in length.

Auto Correlation

If the Web script generator detects a web page form within the current page and successfully matches the contents with any POST or query data sent in subsequent requests an extractForm() method is inserted into the script. The form is subsequently stored in the VU's Data Dictionary using the set() method.

This is shown below where Request 69 returns a page containing the form named "form_69_1". The generator has successfully matched the contents of the web page form with POST data sent in Request 71 and so inserts an extractForm() method.

// ====================================================================================================================================

// Request: 69, GET, http://nopcommerce:58901/cart, response code=200 OK, overlapping top-level requests:[], other overlapping requests:[]

// Rule: Promote Content-Type: text/html sub-requests

// ====================================================================================================================================

// Page Title: Your store. Shopping Cart

// Cookie(s) sent from client:

// Nop.customer=35fc46eb-95cb-4d7e-abdd-ef68b4467df6

// NOPCOMMERCE.AUTH=68D7D25AE21F9D586737AF4EE49D27C716866B86924B9513B09E43B20A5F753CDCF768AE32BEAEC2EEA

// 24B5A30A0D3B3713277BF4A6F630747596665CBCD843516ACBE025336DD83CCEE9622E30577F61EB05BED9C95DC6AD2813CA

// 3CB16245C574A016DB93FD534A832B313302E9E619A295A946A6EB015EF6003028717727522015B19178B88EA921D119CD52638F1

// NopCommerce.RecentlyViewedProducts=RecentlyViewedProductIds=17

// __atuvc=1%7C20

// __atuvs=555ba037b9055d14000

// Cookie(s) set by server:

// Nop.customer=35fc46eb-95cb-4d7e-abdd-ef68b4467df6; expires=Wed, 18-May-2016 20:42:50 GMT; Path=/;

Url url69 = new Url(protocol1, nopcommerce, "/cart");

try (Request request69 = getWebBrowser().createRequest(HttpMethod.GET, url69, 69))

{

request69.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

 

// #region EPP_BEFORE_REQUEST_SENT for Request 69

 

// Any code added here will be preserved between regenerations of this script

 

// #endregion EPP_BEFORE_REQUEST_SENT for Request 69

 

try (Response response69 = request69.send())

{

// #region EPP_AFTER_RESPONSE_RECEIVED for Request 69

 

// Any code added here will be preserved between regenerations of this script

 

// #endregion EPP_AFTER_RESPONSE_RECEIVED for Request 69

 

// Rule: Verify that the page title matches what was recorded

response69.verifyTitle("Your store. Shopping Cart", ActionType.ACT_WARNING);

// Rule: Verify that the result code matches what was recorded

response69.verifyResult(HttpStatus.OK, ActionType.ACT_WARNING);

set("form_69_1", response69.extractForm(1, ActionType.ACT_WARNING));

}

}

Looking at the HTML code of the page returned by Request 69, we see that the form fields in "form_69_1" are prepopulated with the following values:

// Matching form with index=1 found on page index: 69, URL: 'http://nopcommerce/cart'

// Original form values follow:

// Control: CHECKBOX, removefromcart=

// Control: TEXT, itemquantity13714=1

// Control: SELECT-ONE, checkout_attribute_1=1

// Control: TEXT, discountcouponcode=

// Control: TEXT, giftcardcouponcode=

// Control: SELECT-ONE, CountryId=0

// Control: SELECT-ONE, StateProvinceId=0

// Control: TEXT, ZipPostalCode=

// Control: CHECKBOX, termsofservice=

The "form_69_1" object now holds the extracted form field data shown above.

The generator compares the extracted form field values with the POST data values sent in Request 71. The results of the comparison show there were two changes to the form field values. The "termsofservice" field was changed from empty to "true" as a result of the user selecting a checkbox, and a new input element appeared as a result of JavaScript with the key=value pair "checkout=checkout" (don't ask why!).

Due to this, the generator has added

form_69_1.getInputElement("termsofservice").setChecked(true);

and

form_69_1.insertElement(8, new InputElement("checkout", "checkout"));

Form fields not edited by the user are sent back to the server in Request 71 unaltered.

// ====================================================================================================================================

// Request: 71, POST, http://nopcommerce:58901/cart, response code=302 Found, redirect occurred, overlapping top-level requests:[], other overlapping requests:[]

// Rule: Promote Content-Type: text/html sub-requests

// ====================================================================================================================================

// Page Title: Your store. Checkout

// Cookie(s) sent from client:

// Nop.customer=35fc46eb-95cb-4d7e-abdd-ef68b4467df6

// NOPCOMMERCE.AUTH=68D7D25AE21F9D586737AF4EE49D27C716866B86924B9513B09E43B20A5F753CDCF768AE32BEAEC2EEA

// 24B5A30A0D3B3713277BF4A6F630747596665CBCD843516ACBE025336DD83CCEE9622E30577F61EB05BED9C95DC6AD2813CA

// 3CB16245C574A016DB93FD534A832B313302E9E619A295A946A6EB015EF6003028717727522015B19178B88EA921D119CD52638F1

// NopCommerce.RecentlyViewedProducts=RecentlyViewedProductIds=17

// __atuvc=1%7C20

// __atuvs=555ba037b9055d14000

// Cookie(s) set by server:

// Nop.customer=35fc46eb-95cb-4d7e-abdd-ef68b4467df6; expires=Wed, 18-May-2016 20:42:58 GMT; Path=/;

Url url73 = new Url(protocol1, nopcommerce, "/cart");

try (Request request73 = getWebBrowser().createRequest(HttpMethod.POST, url73, 73))

{

request73.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

request73.setHeader("Content-Type", "multipart/form-data; boundary=---------------------------320713130061");

// Matching form with index=1 found on page index: 69, URL: 'http://nopcommerce/cart'

// Original form values follow:

// Control: CHECKBOX, removefromcart=

// Control: TEXT, itemquantity13714=1

// Control: SELECT-ONE, checkout_attribute_1=1

// Control: TEXT, discountcouponcode=

// Control: TEXT, giftcardcouponcode=

// Control: SELECT-ONE, CountryId=0

// Control: SELECT-ONE, StateProvinceId=0

// Control: TEXT, ZipPostalCode=

// Control: CHECKBOX, termsofservice=

Form form_69_1 = ((Form)get("form_69_1")).copy();

form_69_1.getInputElement("termsofservice").setChecked(true);

form_69_1.insertElement(8, new InputElement("checkout", "checkout"));

request73.setMessageBody(form_69_1);

 

// #region EPP_BEFORE_REQUEST_SENT for Request 73

 

// Any code added here will be preserved between regenerations of this script

 

// #endregion EPP_BEFORE_REQUEST_SENT for Request 73

 

try (Response response73 = request73.send())

{

// ...

Dynamically populating POST data at runtime vastly reduces the amount of parameterization required. Many ASP.NET applications use a hidden view state form field to persist changes to the state of a web form across postbacks. The view state can grow very large, often to the order of tens of kilobytes. This will always be handled automatically at runtime by Eggplant Performance despite its length and without the need for parameterization by the user.

 

This topic was last updated on December 06, 2019, at 11:57:50 AM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2020 Eggplant