Web functions

1. web_url():
To launch the application or load the specified URL.

2. web_set_max_html_param_length():
Sets the maximum length of any html string that can be retrieve and stored in a variable.
Syntax: web_set_max_html_param_length(“1024”);

3. web_save_timestamp_param():
Save the timestamp to a parameter. It generates a timestamp in milliseconds which is a 13 digit number.

Syntax: web_save_timestamp_param(“tstamp”,LAST);
lr_output_message(“%s”, lr_eval_string(“{tstamp}”));

4. web_reg_save_param():
Allow you to capture dynamic value from response.

5. web_reg_save_param_ex():
Allow you to capture dynamic value which is introduced from 11.0 version. It has different parameters

6. web_reg_find():
For text verification purpose.

Syntax: web_reg_find("Text=Welcome","SaveCount=Welcome_Count", LAST );

7. web_find():
Text verification purpose. It is deprecated.

8. web_image_check():
Image verification purpose.

Syntax: web_image_check("Text=Welcome", "src=D:\\xyz.gif", LAST );

9. web_set_proxy():
Specifies that all requests should be redirected to a specific proxy server.

Syntax: web_set_proxy(10.10.10.10:8080);
Note: Default port number of https request  443
Default port number of http request  8080

10. web_submit_data():
It is an unconditional context less request which will submit data in form of item data.

11. web_submit_form():
It submits the form and context based request. Submit data in the form of item data.
Note: Context based means request will be dependent on previous response.
Note: Usually we are using web_submit_data option to record scenario.

12. web_get_int_property():
Using this function, you can verify response whether it is proper or not based on HTTP status codes and download size

Syntax:
int HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
lr_output_message(“%d”, HttpRetCode);
if(HttpRetCode == 200)
{
lr_log_message(“Script passed”);
}else
{
lr_log_message(“Script failed”);
lr_abort();
}


13. web_set_user():
For all NTLM (Native Windows Authentication) Applications, we should submit the credentials
against web_server.

Syntax:
web_set_user(“CA:\\Jojo”,”Bean”, HTTP://webtours.kword.com:80);

14. web_set_certificate():
Causes a script to use a specific certificate that is listed in internet explorer registry

Syntax: web_set_certificate (“2”);
Extension: .prm/.cer/.pem

15. web_set_socket_option():
Setting the socket level option for a request

Syntax:
web_set_socket_option(“SSL_VERSION”, “TSL1.1”);
Instead of using above function, you can execute the script using wininet engine but which is not preferable.

16. web_cleanup_cookies()& web_cache_cleanup():
These functions will allow you to cleanup cookie files and cache files from browser. Have to write these functions at end of the script.

17. web_convert_param():
Which will convert a string html to url and url to plain vice versa.

Syntax:
web_convert_param("HTML", "SourceEncoding=HTML", "TargetEncoding=URL", LAST );
web_convert_param("HTML1","SourceEncoding=HTML", "TargetEncoding=PLAIN", LAST );
web_convert_param("Plaintext", "SourceEncoding=HTML","TargetEncoding=URL", LAST );

18. web_add_header():
Scenario 1: My first/any request keep on failing even after conducting correlation and parameterization
Solution: Write web_add_header() function on top of request.
Step 1: Verify correlation and parameterization.
Step 2: Verify whether the page is opening manually or not. If it is opening, then problem is with
header.
Step 3: Verify whether we need to add any SSL.


19. web_custom_request():
It will submit the data in the form of body.
Scenario 1: Based on my previous input, number of fields are changing in current page.
Scenario 2: When I am accessing application in morning, it reported 10 records. In the evening 15 records, next day 20 records. How to make it work for anytime?
Scenario 3: How to write web_custom_request()
Scenario 4: Client asked me to book random number of tickets for every user but based on random number, number of passenger fields are changing in payment page. How to make my
script work for vary number of passengers?
Sol:
int xyz;
char abc[100], lmn[100];
xyz=atoi(lr_eval_string(“{prandpass}”);
for(i=1;i<=xyz;i++)
{ sprint(abc,”pass%d=”, i); //pass1=
strcat(abc,lr_eval_string(“{ppass}”)); //pass1=anand
strcat(abc,”&”); //pass1=anand&
strcat(lmn,abc); }
lr_save_string(lmn,”r_no_pass”);

No comments:

Post a Comment