This is the Gatling recorder script.
val httpProtocol = http
// LaunchURL
.baseURL("https://mywebsite/instance")
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
.connection("keep-alive")
.userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:26.0) Gecko/20100101 Firefox/26.0")
// Login
.exec(http("request_6")
.post("""/cas/login;jsessionid=cN7KK9FvXzsqWjmLxL2M5xjk.undefined?service=https://mywebsite/instance/index.jsp""")
.headers(headers_6)
.param("""username""", """abc""")
.param("""password""", """abcpwd""")
.param("""lt""", """LT-828-wppjtrEoGU6gj9UVFt3soVqQ3mLMwe""")
.param("""execution""", """e1s1""")
.param("""_eventId""", """submit""")
.param("""submit""", """LOGIN"""))
.pause(10)
If we see these three lines:
.param("""username""", """abc""")
.param("""password""", """abcpwd""")
.param("""lt""", """LT-828-wppjtrEoGU6gj9UVFt3soVqQ3mLMwe""")
We will use parametrization for username and password. these are input values we can get from a csv file while running the test. Here "lt" is the parameter for ticket. it was generated by CAS when we Launch the URL.
The following code is the portion of BaseURL response.
<table width="100%">
<tr>
<td>
<label for="username" class="fl-label"><span class="accesskey">U</span>sername:</label>
<input id="username" name="username" class="required" tabindex="1" accesskey="u" type="text" value="" size="25" autocomplete="false"/>
</td>
</tr>
<tr>
<td>
<label for="password" class="fl-label"><span class="accesskey">P</span>assword:</label>
<input id="password" name="password" class="required" tabindex="2" accesskey="p" type="password" value="" size="25" autocomplete="off"/>
</td>
</tr>
<tr>
<td>
<input id="warn" name="warn" value="true" tabindex="3" accesskey="w" type="checkbox" />
<label for="warn"><span class="accesskey">W</span>arn me before logging me into other sites.</label>
<input type="hidden" name="lt" value="LT-828-wppjtrEoGU6gj9UVFt3soVqQ3mLMwe" />
<input type="hidden" name="execution" value="e1s1" />
<input type="hidden" name="_eventId" value="submit" />
</td>
</tr>
<tr>
<td>
<input class="btn-submit" name="submit" accesskey="l" value="LOGIN" tabindex="4" type="submit" />
<input class="btn-reset" name="reset" accesskey="c" value="CLEAR" tabindex="4" type="reset" />
</td>
</tr>
</table>
Here CAS generated ticket "LT-828-wppjtrEoGU6gj9UVFt3soVqQ3mLMwe" in BaseURL Response. Here, I need to extract ticket from the BaseURL Response and use this ticket in Login request.
Previous i extracted ticket using regular expression in Jmeter as name="lt" value="(.*?)" from BaseURL Response.
Please help me how to extract ticket in Gatling.
and can u please tell me how to correlate View states also.
Thanks & Regards
Narasimha
First of all, you will need to make a first GET request to your service as such:
http("getLogin")
.get(casUrl)
Considering the casUrl val contains the path to your actual service, then, and only then, will you be able to retrieve the information you need, let's say, with a css expression:
http("getLogin")
.get(casUrl)
.check(css("input[name='lt']", "value").saveAs("lt"))
Checkers are used to extract data from the body of a request. The saveAs is the important part. It will allow you to record data into gatling's session.
You can reuse it this way:
http("postLogin")
.post(...)
...
.param("lt", "${lt}")
The brackets are also mandatory : it notices Gatling to try and search in the session the value associated with the key lt.
Here is a full example based on your script:
val casUrl = "/cas/login;jsessionid=cN7KK9FvXzsqWjmLxL2M5xjk.undefined?service=https://mywebsite/instance/index.jsp"
val httpProtocol = http
// LaunchURL
.baseURL("https://mywebsite/instance")
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
.connection("keep-alive")
.userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:26.0) Gecko/20100101 Firefox/26.0")
// Login
.exec(
http("getLogin")
.get(casUrl)
.check(css("input[name='lt']", "value").saveAs("lt")))
.exec(
http("postLogin")
.post(casUrl)
.headers(headers_6)
.param("username", "abc")
.param("password", "abcpwd")
.param("lt", "${lt}")
.param("execution", "e1s1")
.param("_eventId", "submit")
.param("submit", "LOGIN"))
I took the liberty to remove the triple quotes, which are not necessary in this use case.
Related
I am working with ejs and mongodb/mongoose and what I am trying to do is rendering the page passing the data to an input type="number" on value attribute, but it is not working.
This is the backend part of the code:
Produto.findOne({_id: requestedProduct}, function(err, produto){
res.render("produtosEditar", {
precoUnitario: produto.precoUnitario
});
});
And this is where I am trying to render it:
<input class="form-control mid-field" type="number" min="0" step="any" name="precoUnitario" value="<%= precoUnitario %> ">
The value stored in db is higher than 0.
When I change the input type to text, it works, but it doesn't when it is a type="number".
This is an edit data page.
Can you help bros?
Thank you!
I'm assuming your precoUnitario variable is a valid number. You need to remove the
extra space at the end of value="<%= precoUnitario %> ">.
You can see the demo below:
<!-- The extra space at the end of value makes it unvalidate -->
<input class="form-control mid-field" type="number" min="0" step="any" name="precoUnitario" value="1.5 ">
<!-- This works -->
<input class="form-control mid-field" type="number" min="0" step="any" name="precoUnitario" value="1.5">
As mentioned in this question's title, when using the boto3.client('s3').generate_presigned_post to generate an upload URL as per here and injecting the response of the function into the following form:
<form class="s3-upload" action="URL_VALUE" method="post" enctype="multipart/form-data">
<input type="hidden" name="key" value="VALUE"/>
<input type="hidden" name="AWSAccessKeyId" value="VALUE"/>
<input type="hidden" name="policy" value="VALUE"/>
<input type="hidden" name="signature" value="VALUE"/>
<input type="hidden" name="success_action_redirect" value="VALUE"/>
<input type="file" name="file" class="upload-input">
<p class="drag-text">Drag your file here or click in this area.</p>
<button id="uploadS3" type="submit" title="">Upload</button>
</form>
I receive the following error from AWS: The AWS Access Key Id you provided does not exist in our records.
The application runs inside a docker on AWS Fargate and has an AWS role attached to it. This must probably have something to do with the solution because the whole functionality works fine on my local machine. Furthermore, all other AWS related operations with S3 (also with SQS) work fine with that AWS Fargate/AWS role setting. I'm looking forward to any suggestions about what to do.
i am working with angular5 , i need to integrate PayUMoney payment gateway in my application , for that i added following form and test with "https://test.payu.in/_payment" domain.
Error :
Error Reason Transaction failed due to incorrectly calculated hash
parameter.
Corrective Action Please ensure that the hash used in transaction
request is calculated using the correct formula. Please note the
correct formula for calculating the value of hash:
sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||SALT)
Based on above formula and applying for this transaction, hash should
be calculated as mentioned below : hash =
sha512(gtKFFx|ba7816bf8f01cfea414140de5da|500|merit application
fees|bhagvat lande|landebm#gmail.com|||||||||||eCwWELxi) = Array
As seen above, correct hash value should have been - Array
But the hash posted in the transaction request from your end was -
e95bd46ce3cf4b3c32a63ba5f51934ef8506e0e47027512f41bff125be02cd14
My Component with Form
<form #f method="post" id="payu-payment-form" action="https://test.payu.in/_payment">
<input type="hidden" name="hash" value="e95bd46ce3cf4b3c32a63ba5f51934ef8506e0e47027512f41bff125be02cd14"/>
<input type="hidden" name="key" value="gtKFFx" />
<input type="hidden" name="txnid" value="ba7816bf8f01cfea414140de5da" />
<input type="hidden" name="amount" value="500" />
<input type="hidden" name="productinfo" value="merit application fees" />
<input type="hidden" name="firstname" value="bhagvat lande" />
<input type="hidden" name="email" value="******#gmail.com" />
<input type="hidden" name="phone" value="+91**********" />
<input type="hidden" name="surl" value="http://localhost:4200/#/payment/payment-success" />
<input type="hidden" name="furl" value="http://localhost:4200/#/payment/payment-error" />
<input type="hidden" name="service_provider" value="" />
<button class="btn btn-info" type="submit" (click)="f.submit()" value="submit" formtarget="_blank"> <i class="fa fa-money"></i> Proceed To Pay</button>
</form>
in above form i just generate one dummy hash key(SHA-256) and put their.
Questions :
how to integrate PayUmoney payment gateway in ANgular2/4/5 ?
they provided formula on their documentation for generation hash key , it tooks all other forms fields and generate hash key (SHA-256) , is their any way to create hash key at client side and how to use that ?
thanks
I'm adding <input> fields in form using jquery html() on click event.
$('#container').html('<input type="text" name="ce" value="some" >');
after submitting php POST i'm unable to see index ce with print_r($_POST);
is there any special method to add elements to dom for this ? please advise.
Solved ! Thanks for answering. in my scenario even with append it didn't work. now it's done with my previous code using html(). Problem was wrapping the <form>. my table is large i'm only pointing out the problem. my structure was suppose to like:
<table>
<tr>
<form id="myform">
<td><input type="text" name="name" ></td>
<td>
<div id="container">
<!-- dynamically generated inside this div against it's id (which didn't work) -->
<input type="text" name="ce" >
</div>
</td>
</form>
</tr>
</table>
i simply Put the entire table into the 'form' tags
<form id="myform">
<table>
<tr>
<td><input type="text" name="name" ></td>
<td>
<div id="container">
<input type="text" name="ce" > <!-- dynamically generated inside div (works!) -->
</div>
</td>
</tr>
</table>
</form>
it worked perfectly with both append() and html(). hope will be helpful for someone.
When you do $('#container').html you are not adding a new input, you are replacing all your content with this new input..
try $('#container').append tag
Look at this example -> https://jsfiddle.net/660a3t1g/
$('#myInputs').append('<input type="text" placeholder="LastName: " name="some" >');
Hey I'm try to make a Windows Phone app that logs people in to a webpage, but I'm having trouble getting the app to post the log-in info to the webbrowser.
on the desktop I would have used
HTMLInputElement nameBox = (HTMLInputElement) myDoc.all.item("name", 0);
HTMLInputElement passBox = (HTMLInputElement) myDoc.all.item("pass", 0);
nameBox.value = "textBox1.text";
passBox.value = "textBox2.text;
but the HTMLInputElemet don't exist in Windows Phone.
I also tried using webBrowser1.document but that don't work either on Windows Phone.
It is a log-in using a form and not a query string.
The server side code look like this:
<div class="form-item textfield edit-name">
<div class="label">
<label >E-mail-adresse</label>
</div>
<input type="text" maxlength="60" placeholder="" name="name" id="edit-name" size="60" value="" class="form-text required" /> </div>
<div class="form-item password edit-pass">
<div class="label">
<label >Adgangskode</label>
</div>
<input type="password" name="pass" id="edit-pass" maxlength="128" size="60" class="form-text required" /> </div>
<input type="hidden" name="form_build_id" id="form-b6cb750ff3a79c34d408df98d730a39e" value="form-b6cb750ff3a79c34d408df98d730a39e" />
<input type="hidden" name="form_id" id="edit-user-login" value="user_login" />
<div class="form-actions"><input type="submit" name="op" id="edit-submit" value="Log ind" class="form-submit" />
It is easy in the desktop but I just cant figure out how to do this on the Phone, hope some one can help.
One way to access the fields is using Javascript, thanks to the InvokeScript method:
webBrowser1.InvokeScript("eval", string.Format("document.getElementsByName('name')[0].value='{0}'", "PutTheLoginHere"));