Below is my html code
<tr role="row" class="even">
<td class="sorting_1">AMT New Test Class</td>
<td>FY19 - W14
<br>Apr-30-2018</td>
<td>FY19 - W14
<br>May-1-2018</td>
<td><span data-toggle="tooltip" data-original-title="Calendar"><i class="fa fa-calendar m-r-10" aria-hidden="true"></i></span><span data-toggle="tooltip" data-original-title="Copy"><i class="fa fa-clone m-r-10" aria-hidden="true"></i></span><span data-toggle="tooltip" style="cursor:pointer" data-original-title="Training Geography not available" onclick="doNothing(event)"><i class="fa fa-globe m-r-10" aria-hidden="true"></i></span><span data-toggle="tooltip" style="cursor:pointer" data-original-title="Comments: " onclick="doNothing(event)"><i class="fa fa-commenting m-r-10" aria-hidden="true"></i></span></td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">AMT New Test Class</td>
<td>FY19 - W14<br>Apr-30-2018</td>
<td>FY19 - W14<br>May-1-2018</td>
<td><span data-toggle="tooltip" data-original-title="Calendar"><i class="fa fa-calendar m-r-10" aria-hidden="true"></i></span><span data-toggle="tooltip" data-original-title="Copy"><i class="fa fa-clone m-r-10" aria-hidden="true"></i></span><span data-toggle="tooltip" style="cursor:pointer" data-original-title="Training Geography not available" onclick="doNothing(event)"><i class="fa fa-globe m-r-10" aria-hidden="true"></i></span><span data-toggle="tooltip" style="cursor:pointer" data-original-title="Comments: " onclick="doNothing(event)"><i class="fa fa-commenting m-r-10" aria-hidden="true"></i></span></td>
</tr>
My vugen script looks like
web_submit_data("getClassDetails_2",
"Action= websiteURL /getClassDetails",
"Method=POST",
"RecContentType=application/json",
"Referer= websiteURL /manage_schedules",
"Snapshot=t320.inf",
"Mode=HTTP",
ITEMDATA,
"Name=draw", "Value=1", ENDITEM,
"Name=columns", "Value=classSubtypeMaster.classSubtypeName,classSubtypeMaster.classSubtypeKey,divRegJson,finalWeekMapJson,finalWeekMapJson,createdOnDate,createdByUserId,scheduleClassMainKey,scheduleStartId.clndrDate,scheduleEndId.clndrDate,occrStartFiscalWeek,occrEndFiscalWeek,comments", ENDITEM,
"Name=order[0][column]", "Value=0", ENDITEM,
"Name=order[0][dir]", "Value=asc", ENDITEM,
"Name=start", "Value=0", ENDITEM,
"Name=length", "Value=10", ENDITEM,
"Name=search[value]", "Value=", ENDITEM,
"Name=search[regex]", "Value=false", ENDITEM,
"Name=nodeList", "Value=18", ENDITEM,
"Name=nodeIdList", "Value=3", ENDITEM,
"Name=searchColumns", "Value=classSubtypeMaster.classSubtypeKey,divRegJson,finalWeekMapJson", ENDITEM,
LAST);
before this step i am placing these below web_reg_save_param_ex functions
And i tried with the below web_reg_save_param_ex
1st Try
web_reg_save_param_ex(
"ParamName=scheduleClassMainKey",
"LB=onclick=\"openCalenderModal(event,",
"RB=)\" class=\"calenderPop\">",
"NotFound=error",
"Ordinal=all",
SEARCH_FILTERS,
"Scope=BODY",
"IgnoreRedirections=Yes",
LAST);
2nd Try
web_reg_save_param_ex(
"ParamName=scheduleClassMainKey",
"LB/RE=<a href=\"copySchedule?scheduleClassMainKey=",
"RB=&type=copySchedule\"><i ",
"NotFound=warning",
"Ordinal=all",
SEARCH_FILTERS,
"Scope=ALL",
"IgnoreRedirections=Yes",
LAST);
But getting error in output
1st Try output
Action.c(213): web_reg_save_param_ex started [MsgId: MMSG-26355]
Action.c(213): Registering web_reg_save_param_ex was successful [MsgId: MMSG-26390]
Action.c(224): web_submit_data("getClassDetails") started [MsgId: MMSG-26355]
Action.c(224): Error -26377: No match found for the requested parameter "scheduleClassMainKey". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size [MsgId: MERR-26377]
Action.c(224): Notify: Saving Parameter "scheduleClassMainKey_count = 0"
saving the parameters as lr_output_message("PC:%d",atoi(lr_eval_string("{scheduleClassMainKey_count}")));
and
2nd Try
Action.c(245): Notify: Parameter Substitution: parameter "scheduleClassMainKey_count" = "0"
Action.c(245): 0
Action.c(246): Warning:
Based on the comments tried but still getting below error in output pane:
Action.c(203): web_submit_data("getClassDetails_2") started [MsgId: MMSG-26355]
Action.c(203): Error -26377: No match found for the requested parameter "scheduleClassMainKey". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size [MsgId: MERR-26377]
Action.c(203): Error -26377: No match found for the requested parameter "_scheduleClassMainKey". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size [MsgId: MERR-26377]
Action.c(203): web_submit_data("getClassDetails_2") highest severity level was "ERROR", 177 body bytes, 510 header bytes, 11 chunking overhead bytes [MsgId: MMSG-26387]
Ending action Action.
can anyone tell me where am i doing wrong.
Both simplified versions of web_reg_save_param_ex successfully extract values from the provided response fragment.
web_reg_save_param_ex(
"ParamName=scheduleClassMainKey",
"LB=onclick=\"openCalenderModal(event,",
"RB=)\" class=\"calenderPop\">",
"Ordinal=all",
SEARCH_FILTERS,
"Scope=Body",
LAST);
web_reg_save_param_ex(
"ParamName=_scheduleClassMainKey",
"LB=<a href=\"copySchedule?scheduleClassMainKey=",
"RB=&type=copySchedule\"><i ",
"Ordinal=all",
SEARCH_FILTERS,
"Scope=Body",
LAST);
Output:
Notify: Saving Parameter "scheduleClassMainKey_1 = 393517".
Notify: Saving Parameter "_scheduleClassMainKey_1 = 393517".
Notify: Saving Parameter "scheduleClassMainKey_2 = 393528".
Notify: Saving Parameter "_scheduleClassMainKey_2 = 393528".
...
Notify: Saving Parameter "scheduleClassMainKey_count = 2".
Notify: Saving Parameter "_scheduleClassMainKey_count = 2".
Please, validate that you have not another errors/warnings in the replay log and that actual server response contains the expected html code.
Following your last update. This quote from replay log shows that the response body size was much smaller (177 bytes) relatively to provided response fragment.
Action.c(203): web_submit_data("getClassDetails_2") highest severity level was "ERROR", 177 body bytes, 510 header bytes, 11 chunking overhead bytes
Please, enable Extended log in Run-Time Settings that include "Advanced trace" and "Data returned by server" and run the script again to see whether the actual server response contains the expected data.
Are you saving both parameters to the same name "scheduleClassMainKey"?
Also,
According to the documentation:
The web_reg_save_param_ex function also supports array type parameters. When
you specify Ordinal=All, all the occurrences of the match are saved in an
array. Each element of the array is represented by the ParamName_index. See
Example of Parameter Arrays.
In the following example, the parameter name is A:
web_reg_save_param_ex("ParamName=A", "LB/ic=<a href=", "RB=\'>",
"Ordinal=All", LAST );
The first match is saved as A_1, the second match is saved as A_2, and so
forth. You can retrieve the total number of matches by using the following
term: ParamName_count. For example, to retrieve the total number of matches
saved to the parameter array, use:
TotalNumberOfMatches=atoi(lr_eval_string("{A_count}"));
Therefore the parameter you need to use is scheduleClassMainKey_1
Related
I am writing a python flask function that uses a flash() to give a user an opportunity to undo an action. I am trying to present a variable "task_id" within a Markup(). This variable is defined earlier in the function before the flash is called. I am trying to assign a data-* attribute the value of this variable, but it is not working.
flash(task_name + " was marked complete " + Markup('<a href="#" class="toggle_task" data-task_id=task_id>UNDO</a>'))
I also tried using jinja syntax, like {{task_id}} but this does not work either. How can I pass a variable into the Markup()?
Try this:
flash(task_name + " was marked complete " + Markup('<a href="#" class="toggle_task" data-task_id={}>UNDO</a>'.format(task_id)))
I am trying to write a script to click an icon which is a part of the table header. Each column in the table has this icon in it (ascending order and descending order sorting icons). I am using Geb to do this. Here is how I am trying to do it:
In my SortingSpec.groovy file:
header.closest("div.customSortDownLabel").click()
I also tried
header.siblings('div.customSortDownLabel').first().click()
In the SortingPage.groovy file:
header {
grid.$(class: 'div.customHeaderLabel', text: 'Country')
}
In my html:
<div>
<div class="customHeaderLabel">{{params.displayName}}</div>
<div *ngIf="params.enableSorting" (click)="onSortRequested('asc', $event)" [ngClass]="ascSort" class="customSortDownLabel">
<i class="fa fa-long-arrow-alt-down"></i></div>
<div *ngIf="params.enableSorting" (click)="onSortRequested('desc', $event)" [ngClass]="descSort" class="customSortUpLabel">
</div>
None of them worked for me. It is not able to find the selector. Any suggestions are appreciated.
Error I see is:
geb.error.RequiredPageContentNotPresent: The required page content 'header - SimplePageContent (owner: SortingGrid, args: [], value: null)' is not present
That error looks like header isn't matching. Assuming that grid matches, and you're using some Javascript framework like Angular to substitute 'Country' for params.displayName, I would guess that maybe Geb is failing to find header before 'Country' is substituted. So, I would try making header wait for it:
header(wait: true) { grid.$(class: 'div.customHeaderLabel', text: 'Country') }
By the way, closest() goes in the wrong direction, to an ancestor, but siblings() looks good.
siblings() didnt work for me but next() worked for me. next() grabs the next sibling elements of the current context elements.
Example:
1. header.next().click() clicks the very next sibling
header.next("div.customSortDownLabel").click() looks for the very next sibling with the matching selector of 'div.customSortDownLabel' and then clicks it.
I was hoping one of you may be able to help answer this scripting problem I am having
In one of my correlations I have a parameter being saved like so…
C_RegionValue = “N/A”
However when I need replace this value into one of my URL’s the N/A needs to change to N%2FA
So I am accomplishing this by:
if ( (strcmp("N/A", lr_eval_string("{C_RegionValue}"))) == 0){
lr_save_string("N%2FA", "C_RegionValue");
}
And this is working properly
do_create_RegionString.c(16): Notify: Saving Parameter "C_RegionValue = N/A".
do_create_RegionString.c(18): Notify: Parameter Substitution: parameter "C_RegionValue" = "N/A"
do_create_RegionString.c(19): Notify: Saving Parameter "C_RegionValue = N%2FA".
And I am even able to use that new parameter again in subsequent calls
lr_param_sprintf("temp_RString", "&vs_geoType_%d=Region&vs_geo_%d=%s", i, i,
lr_eval_string("{C_RegionValue}"));
do_create_RegionString.c(23): Notify: Parameter Substitution: parameter "C_RegionValue" = "N%2FA"
do_create_RegionString.c(23): Notify: Saving Parameter "temp_RString = &vs_geoType_6=Region&vs_geo_6=N%2FA".
But for some reason I am not able to use it on this call
lr_param_sprintf(lr_eval_string("{RegionString}"), lr_eval_string("{P_RGet_TmpVal}{temp_RString}"));
No errors it just never saves the new value, It substitutes everything properly but the value is never saved.
I know this section of the code is working because it does it 5 times prior to this call.
do_create_RegionString.c(35): Notify: Parameter Substitution: parameter "RegionString" = "PickAnyRegion_XL"
do_create_RegionString.c(35): Notify: Parameter Substitution: parameter "P_RGet_TmpVal" = "&vs_geoType_0=Region&vs_geo_0=Global (All Regions)&vs_geoType_1=Region&vs_geo_1=E&vs_geoType_2=Region&vs_geo_2=GC&vs_geoType_3=Region&vs_geo_3=I&vs_geoType_4=Region&vs_geo_4=NA&vs_geoType_5=Region&vs_geo_5=SA"
do_create_RegionString.c(35): Notify: Parameter Substitution: parameter "temp_RString" = "&vs_geoType_6=Region&vs_geo_6=N%2FA"
And it gets even weirder, If I do not change the value to N%2FA and leave it as N/A, or even if I use the same If statement and change the value to back to N/A everything works properly…
do_create_RegionString.c(35): Notify: Parameter Substitution: parameter "RegionString" = "PickAnyRegion_XL"
do_create_RegionString.c(35): Notify: Parameter Substitution: parameter "P_RGet_TmpVal" = "&vs_geoType_0=Region&vs_geo_0=Global (All Regions)&vs_geoType_1=Region&vs_geo_1=E&vs_geoType_2=Region&vs_geo_2=GC&vs_geoType_3=Region&vs_geo_3=I&vs_geoType_4=Region&vs_geo_4=NA&vs_geoType_5=Region&vs_geo_5=SA"
do_create_RegionString.c(35): Notify: Parameter Substitution: parameter "temp_RString" = "&vs_geoType_6=Region&vs_geo_6=N/A"
do_create_RegionString.c(35): Notify: Saving Parameter "PickAnyRegion_XL = &vs_geoType_0=Region&vs_geo_0=Global (All Regions)&vs_geoType_1=Region&vs_geo_1=E&vs_geoType_2=Region&vs_geo_2=GC&vs_geoType_3=Region&vs_geo_3=I&vs_geoType_4=Region&vs_geo_4=NA&vs_geoType_5=Region&vs_geo_5=SA&vs_geoType_6=Region&vs_geo_6=N/A".
Any thoughts or idea’s here?
EDIT:
Here is a better example
Action()
{
lr_save_string("N/A","C_RegionValue");
lr_save_string("XL_PickAnySearch", "RegionString");
lr_save_string("&vs_geoType_0=Region&vs_geo_0=test","temp_RString");
lr_save_string(lr_eval_string("{temp_RString}"), "XL_PickAnySearch");
/*
Lines 12-13 section will convert N/A into N%2FA, if left uncommented Line 20
will not save the string, if commented line 20 will save the string
*/
web_convert_param("C_RegionValue", "SourceEncoding=PLAIN",
"TargetEncoding=URL", LAST);
lr_param_sprintf("temp_RString", "&vs_geoType_%d=Region&vs_geo_%d=%s", 1, 1,
lr_eval_string("{C_RegionValue}"));
lr_param_sprintf("P_RTmpVal", "{%s}", lr_eval_string("{RegionString}"));
lr_param_sprintf("P_RGet_TmpVal", "%s", lr_eval_string(lr_eval_string("{P_RTmpVal}")));
lr_param_sprintf(lr_eval_string("{RegionString}"), lr_eval_string("{P_RGet_TmpVal}{temp_RString}"));
return 0;
}
EDIT: Could you be just missing the %s in the last call?
lr_param_sprintf(lr_eval_string("{RegionString}"),"%s", lr_eval_string("{P_RGet_TmpVal}{temp_RString}"));
I am not sure I understand your problem but I will try and give you couple of directions to go on.
1) lr_param_sprintf takes the parameter name as the first argument but it seems you are trying to send it an evaluated parameter in lr_param_sprintf(lr_eval_string("{RegionString}"), ...
Maybe you mean lr_param_sprintf("RegionString",...)?
2) The change of 'N/A' into 'N%2FA' is known as URL encoding. You can do it without the if with a built in function. See example:
lr_save_string("N/A","C_RegionValue");
web_convert_param("C_RegionValue", "SourceEncoding=PLAIN",
"TargetEncoding=URL", LAST);
lr_save_string("CA","C_RegionValue");
web_convert_param("C_RegionValue", "SourceEncoding=PLAIN",
"TargetEncoding=URL", LAST);
Output:
Action.c(3): Notify: Saving Parameter "C_RegionValue = N/A".
Action.c(5): web_convert_param started [MsgId: MMSG-26355]
Action.c(5): Notify: Saving Parameter "C_RegionValue = N%2FA".
Action.c(5): web_convert_param was successful [MsgId: MMSG-26392]
Action.c(9): Notify: Saving Parameter "C_RegionValue = CA".
Action.c(10): web_convert_param started [MsgId: MMSG-26355]
Action.c(10): Notify: Saving Parameter "C_RegionValue = CA".
Action.c(10): web_convert_param was successful [MsgId: MMSG-26392]
We recommend doing all the manipulations first and making the call to web_convert_param only when the final URL is ready.
Hope this helps.
How do I get the email address from this html snippet?
As there are thousand of leads like this in a certain webpage and the text within it is not always found as it is seen here.
The only common thing is the email address located in the first position.
How can I get the email address and ignore the rest?
These are the elements:
<div class="gm_popup"><div class="gm_name">Adel Outfitters</div><div class="gm_address">1221 W 4th St</div><div class="gm_location">Adel, Georgia 31620<div style="display:none" class="w3-address-country">United States</div></div><div class="gm_phone"><span class="gm_phone_label">P:</span> 229-896-7105</div><div class="gm_email">adeloutfitters#yahoo.com<div><div class="gm_website">https://www.facebook.com/pages/Adel-Outfitters/132735763434461</div><br><a target="_blank" class="directions-link" href="http://maps.google.com/?saddr=+&daddr=1221+W 4th St, Adel, Georgia, 31620">Directions<span class="w3-arrow">different stuffs</span></a></div></div></div>
What I tried:
Set post = html.getElementsByClassName("gm_email")(0)
MsgBox post.innerText
The result:
adeloutfitters#yahoo.com
https://www.facebook.com/pages/Adel-Outfitters/132735763434461
Directionsdifferent stuffs
Expected output:
adeloutfitters#yahoo.com
The closing </div> tag is further down which is why you are getting the extra text. Can you chop off anything after a new line? Or check each word in the string and save the one with "#" in it? Bad way of going about it, but it would probably work...
how can i specify height and width of an image if i use html::image() in koahana 3. if i pass all attributes in an array it says that string expected instead of array ......please help
echo "<td class='".$class."' align='left' style='border-left:1px solid #D3D3D3'>
<a class='list_title' href='".$editBannerHref."'>".
html::image(array("src"=>"media/uploads/video_portal thumbnail".$videos[$count]->image,"alt"=>"","width"=>60,"height"=>50))."</a><br/>
<a href='".$playVideo."'>View Video</a></td>";
First parameter is file name, second attributes - http://kohanaframework.org/3.2/guide/api/HTML#image
This is the correct usage:
HTML::image("media/uploads/video_portal thumbnail".$videos[$count]->image, array("alt"=>"", "width"=>60, "height"=>50))