Extract hidden value from html response

1,435 views
Skip to first unread message

Aditya Agrawal

unread,
Dec 11, 2015, 9:34:10 AM12/11/15
to Gatling User Group
Hi,

I'm trying to capture hidden fields from html response, for some ids it's working but not for all.

HTML Response: (Sample)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    ...
</head>

<body class="bodyBg">
    ...
   
<input attr-ignore-in-post='****' type='hidden' id='invoiceHeaderRowId' value='1252277'>
 ...
   
<div class='three columns display-none' id='invoiceHeaderExts.invoiceHeaderExtRowIdcontainer'>
       
<label class='  ' id='invoiceHeaderExts.invoiceHeaderExtRowId-label' for='invoiceHeaderExts.invoiceHeaderExtRowId'>&nbsp;</label>
       
<div class='field'>
           
<input type="text" id="invoiceHeaderExts.invoiceHeaderExtRowId" name="invoiceHeaderExts.invoiceHeaderExtRowId" attr-type="****"  attr-two-phase="****" value="2495" class="input display-none" />
       
</div>
       
<div id='invoiceHeaderExts_invoiceHeaderExtRowId_error_message' class='detail-view-error-message'>&nbsp;</div>
   
</div>
    ...
   
<input type='hidden' id='invoiceStatus' value="HOLD" attr-two-phase="*****"> ...
</body>
</html>


Gatling HTTP Request:
.exec(http("DetailPage")
 
.post("/***/ajax/***")
 
.headers(headers_2)
 
.resources(http("BillDetail")
 
.post(uri1 + "/router/***/simple-read.htm")
 
.headers(headers_0)
 
.formParam("entityId", "BillEntity")
 
.formParam("rowId", "${BillRowId}")
 
...
 
.formParam("exportConfigurationRowId", "")
 
.check(css("#invoiceHeaderExts.invoiceHeaderExtRowId", "value").saveAs("InvoiceExtRowId"))
 
.check(css("#invoiceStatus", "value").find.saveAs("Old_InvoiceStatus")))
 
)

Here I'm able to capture "#invoiceStatus" value successfully, but not for "#invoiceHeaderExts.invoiceHeaderExtRowId".

I tried many combination (mentioned below) but no luck, same time all are working for "#invoiceHeaderRowId" & "#invoiceStatus".

.check(css("#invoiceHeaderExts.invoiceHeaderExtRowId", "value").saveAs("InvoiceExtRowId"))
.check(css("input[id$='invoiceHeaderExtRowId']", "value").saveAs("InvoiceExtRowId"))
.check(css("input[id='invoiceHeaderExts.invoiceHeaderExtRowId']", "value").find.saveAs("InvoiceExtRowId"))


Can someone please help me to solve this?

Thanks & Regards,
Aditya Agrawal

Stéphane LANDELLE

unread,
Dec 11, 2015, 10:20:52 AM12/11/15
to gat...@googlegroups.com
 .check(css("#invoiceHeaderExts.invoiceHeaderExtRowId", "value").saveAs("InvoiceExtRowId"))

dot is a special character, as it's used for a class selector. You have to escape it with backslash.

.check(css("input[id='invoiceHeaderExts.invoiceHeaderExtRowId']", "value").find.saveAs("InvoiceExtRowId"))

should work. You probably have a typo somewhere.

Stéphane Landelle
GatlingCorp CEO


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aditya Agrawal

unread,
Dec 11, 2015, 11:20:53 AM12/11/15
to Gatling User Group
Thanks Stéphane for quick response.

I rechecked the typo, i don't see any issue. I will try with backslash and see if it works.

Anyway, Thanks once again.

-Aditya

Satish Kumar G

unread,
May 9, 2019, 11:49:08 AM5/9/19
to Gatling User Group
.find is missing

.check(css("input[id='invoiceHeaderExts.invoiceHeaderExtRowId']", "value").find.saveAs("InvoiceExtRowId"))

slan...@gatling.io

unread,
May 9, 2019, 11:50:02 AM5/9/19
to gat...@googlegroups.com
No it’s not: it’s the default value for this step.
Reply all
Reply to author
Forward
0 new messages