how to use web_reg_save_param_xpath in load runner? - performance

I have below response for one of the request I would to fetch the value 5 using web_reg_save_param_xpath, I have tried with below expression.
Expression:
web_reg_save_param_xpath(
"ParamName=WarehouseId",
"ReturnXml=No",
"QueryString=.//select[#id='WareHouseId']/option[#selected='selected']/#value",
"SelectAll=No",
SEARCH_FILTERS,
"Scope=BODY",
LAST);
Response data:
<select class="form-control" data-val="true" data-val-number="The field Warehouse must be a number." data-val-range="[Warehouse] Minimum value should be 0" data-val-range-max="2147483647" data-val-range-min="0" data-val-regex="[Warehouse] Please enter valid input." data-val-regex-pattern="[0-9]+$" data-val-required="Warehouse is mandatory." id="WareHouseId" name="WareHouseId">
<option value="">--Select--</option>
<option value="4">Hospital</option>
<option selected="selected" value="5">Warehouse</option>
<option value="6">SUPPLY</option>
</select>
but it throwing below error
Action.c(301): Error: lr_xml_get_values_reg_save_param execution failed
Action.c(301): Notify: Saving Parameter "ReasonId = 4".
Action.c(301): Notify: Saving Parameter "WarehouseId = ".
Action.c(301): Error -35060: No matches were found for the specified query: ".//select[#id="WareHouseId"]/option[#selected="selected"]/#value" [MsgId: MERR-35060]

Related

Submit a disabled selected option in a Codeception Functional test

I'm trying to test my backend by passing invalid options to it. I have a select item like so:
<label for="title">Title</label>
<select id="title" name="title" required="required">
<option value="" disabled="" selected="selected">Select one</option>
<option value="Mr">Mr</option>
<option value="Ms">Ms</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
<option value="Sir">Sir</option>
<option value="Prof">Prof</option>
</select>
The user must select an option, but there's no sensible default for a person's title so "Select one" is displayed, but can't be reselected once another option has been chosen.
However, in the Functional test
If I don't select anything, Mr (the first non-disabled option) gets submitted.
If I try to explicitly set Select one with the following code:
$I->selectOption('title', 'Select one');
I get a message saying:
[InvalidArgumentException] Input "title" cannot take "" as a value (possible values: "Mr", "Ms", "Mrs", "Miss", "Dr", "Sir", "Prof").
How can I get a Codeception Functional test to submit a disabled, selected <option/>?

how to dynamically option the selected in html just using php?

I'm trying to dynamically the select option selected just using php in laravel but I'm getting this error:
Use of undefined constant selected - assumed 'selected' (this will
throw an Error in a future version of PHP) (View:
C:\xampp\htdocs\laralast\resources\views\view.blade.php)
below is my view blade
<select class="form-control" name="assign_to" id="assign_to">
<option selected disabled>Select support</option>
#foreach($supports as $support)
<option value="{{$support->id}}" {{($ticket->assign_by == $support->id ? selected : '')}}>{{$support->fullname}}</option>
#endforeach
</select>
Can you help me with this.
You should quote your string (I mean you should quote the selected):
<option value="{{$support->id}}" {{($ticket->assign_by == $support->id ? 'selected' : '')}}>{{$support->fullname}}</option>
Your laravel is understanding that you will print the value of selected constant (since no dollar-sign $, no string quotation '' "") when the condition is true.
Please Check This use if & else
<select class="form-control" name="assign_to" id="assign_to">
<option selected disabled>Select support</option>
#foreach($supports as $support)
#if($ticket->assign_by == $support->id)
<option value="{{$support->id}}" selected>{{$support->fullname}}
</option>
#else
<option value="{{$support->id}}">{{$support->fullname}}</option>
#endforeach
</select>

october cms ajax and options values

Is it possible to send value from options on example like this where x need to be value from option. This select im using on partial and ajax works with manualy added value as x. THX!
<select data-request-data = "id: x " class="form-control custom-select" data-request="onChangeValue">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
Just give your select a name, an unique name.
name="some_unique_name"
<select name="my_super_special_name_for_select" class="form-control custom-select" data-request="onChangeValue">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
Then when you change the value the value of the field is sent along in post
The result of:
public function onChangeValue()
{
traceLog(post());
}
In the log you will see then a result corresponding to
["my_super_special_name_for_select" => 5 ]
So you can fetch it with post('my_super_special_name_for_select') or whatever name you have given the select element to get the value.
public function onChangeValue()
{
$id = post('my_super_special_name_for_select');
}
Yes you can send value from select. But for this you will need to put it inside a form and then call data request on it. Value will be sent as part of post(). It can't be sent dynamically like the way you are using. if you can elaborate your external conditions more I can suggest other solutions too.

Getting value for select from request parameters instead of model object in Thymeleaf

I have a filters form in HTML that sends filtering instructions with GET request. After filtering my <select>s don't load values from passed request parameters but <input>s do with their th:value. How can I instruct <select> to get selected value from URL parameters (passed with GET)? I know I can get values from object in model with th:field but that is not what I want to do, the data I want this controls to select is passed in the request.
This is working well for <input>:
<input th:value="${param.minFee}" placeholder="Min. Fee" class="form-control" type="number" min="0" max="100" step="0.01" id="minFee" name="minFee"/>
How can I make this <select> obtain its selected value from request params?
<select class="form-control" name="payingCurrency" id="payingCurrency">
<option th:value="-1">Any</option>
<option th:each="currency : ${currencies}"
th:value="${currency}"
th:text="${currency.name}"></option>
</select>
For this you should use th:selected.
<select class="form-control" name="payingCurrency" id="payingCurrency">
<option th:value="-1">Any</option>
<option th:each="currency : ${currencies}"
th:value="${currency}"
th:text="${currency.name}"
th:selected="${param.currency == currency}" />
</select>
With the important party being th:selected="${param.currency == currency}". (Where param.currency should evaluate to the parameter you are using.)

Select input ,selected Text codeigniter

I have form with input select in the aplication/view codeigniter
and the form is submited by codeigniter, no ajax.
<select name="sel_options">
<option value="1">hi</option>
<option value="2" selected>bye</option>
</select>
in my aplication/controller
$this->input->post("sel_options");
result:
2
but i need the text ("bye");
When you post a value, it's going to use the value from the input. So in your case:
<select name="sel_options">
<option value="1">hi</option>
<option value="<!-- I'm Submitting this value -->" selected>bye</option>
</select>
The value for the second option is 2 (<option value="2" ... />) if you wanted to pull in the value from the html ('bye'), you'd have to set the value to be bye.
<option value="bye" selected>bye</option>

Resources