Citrix ICA Protocol


Citrix_ ICA Protocol: If the application deployed in citrix environment we have to use Citrix _ ICA protocol. But my current project deployed in citrix. Before accessing this application we have to connect to the citrix env. Through citrix protocol.
VDA – (Virtual Desktop Access).
VDI – Virtual Desktop Intra-structure.
These are two ways we can access the application.

1.Through web:
In this case we require to use multiprotocol. (Web+Citrix+ICA).

2.Through client (citrix):
Citrix is a software allow you to access remote profile.
*Xenapp:
Application will be shared in between the users
Xen Desktop:
Application will be published individually
Steps to Access the application:
Access the citrix Env. Through UR
Provide credentials & access the application which is published in citrix Env.
Perform the business scenario against the application.
Log off from the application and from citrix

Prerequisites:
Install citrix_Ica agent in vugen as well as in LG machines (same version of citrix).
Stream less mode should be off.
Try to use only keyboard strokes.
Create virtual channels.
Use the same resolution for Vugen machine as well as LG’s.
Use proper think time for every request.
DEP settings should be disable.
Color depth should be same in LG as well as vugen machine.

Functions:
ctrx_nfuse_connect(): connects to a citrix server via an NFUSE portal.
ctrx_sync_on_window(): waits until a window is created (or) become active.
ctrx_mouse_click(): Emulates a mouse click on a citrix client sent to a citrix server.
ctrx_wait_for_event(): It is a synchronization function that waits for an event to occur.
ctrx_get_window_name(): Retrieves the name of the active window.
ctrx_type(): Emulates a typing alpha numeric keys.
ctrx_sync_on_bitmap(): waits until a bitmap appears.
Ctrx_sync_on_text(): waits until the text is appeared
Ctrx_mouse_click(): emulate the mouse click
Ctrx_get_text(): to capture text from rectangular.
Ctrx_key(): emulates non alpha numeric press.
Ctrx_win_exist(): checks a window is visible or not

Challenges:
1) My test got failed in controller
Cause: citrix_ICA agent version is different in LG & vugen machines.
My mouse click objects were failed in controller.

Cause: Resolution is different in LG & vugen         machines.

Synchronization issue: I have to instruct the users to wait until the response received from server it is called synchronization issue.

Case study 1: Synchronization issue is the biggest issue in citrix protocol. To overcome synchronization issue we have 4 ways.
Based on window name
Based on bitmap value
Based on wait for an event function
Based on sync text

i) Based on window name:
I recorded a script for every action it generated ctrx_sync_window () function. Which will wait for the expected window for a specified time.
To perform new action we have to verify whether the correct window appeared or not. For this verification I used function ctrx_get_window_name() to capture the active window name.
From the above if the active window name is expected window name then we can continue to the next action. Else we have to instruct the vuser to wait until specified window name to be appeared.
Shiva:---  lable
          Ctrx_sync_on_window ( “editing a customer “, activate, 232, 244, 536, “snapshot6”,
CONTINUE_ON_ERROR, CTRX, LAST);
Ctrx_get_window_name(window – name , ctrx-LAST);
If(“Editing < Customer”,window_name)==0)
{
      Lr_output_message(“pass”);
}
else
{
      Lr_output_message(“fail”);
      goto shiva;
}

ii) Based on the Bitmap value:
Using bitmap hash value we can overcome the synchronization issue.
Using  ctrx_get_bitmap_value()  we can capture hash value of any image which can compare with expected Hash value.
Ctrx_get_bitmap_value(672,280,97,18,text_buffer,snapshot_1,CONTINUE_ON_ERROR,CTRX_LAST);
If(strcmp(“04308587……”,text_buffer)==0)
{
         Lr_output_message(“pass”);
}
else
{
         Lr_output_message(“fail”);
}

iii) Based on wait for an event function:
ctrx_wait_for_event () function wait for a specified event to occur.
iv) Based on sync text ():
waits until specified text is displayed around the specific position.
Vijay= ctrx_sync_on_text_ocr (514,313,50,16 ,”company”, ”NULL=snapshot_3”,
CONTINUE_ON_ERROR, CTRX_LAST);
Lr_output_message (“vijay value is %d”, vijay);

4.Challenge: To capture the specific text from on screen (or) capture dynamic value from screen
Solution: using ctrx_get_text() function to capture on screen text to handle text verification points (or) to capture dynamic value.



Q2: How to capture on screen text?
                          OR
       When I am navigating one of the screen displaying dynamic number which has to be captured and pass to the next request?
Sol: ctrx_get_text_ocr (NULL, 515,314,50,14,”snapshot_4”,text_buffer,CONTINUE_ON_ERROR);
Vijay=
ctrx_sync_on_text_ocr(514,313,50,16,”company”,”NULL=snapshot_3”,CONTINUE_ON_ERROR);

Lr_output_message (“vijay value is %d”, vijay);

Q3: How to save an image to a folder?
Sol: ctrx_sync_on_window (“kw hotels free(0,46.129)-[calender]”, Activate,
ctrx_save_bitmap (10,50,100,200,”shiva.bmp”);

SCRIPT DEVELOPMENT TECHNIQUES:
Use proper think time
Create recovery scenario using modular approach
Avoid mouse clicks
Develop session cleaning mechanism
Below things you have to remember before going for execution
Session overlapping would be avoided
If first user fails at 10th page second user should start from 1st page
Window position should be same for all the users
User has to run as a process



The following example will helps you.

Action()
{
 char window_name[100];
 char buffer[50];
 int text;
 
 web_add_cookie("CtxsDeviceId=WR_r4uoM4xicm2E; DOMAIN=ctx.shaft.com");

 web_url("storeweb", 
  "URL=http://ctx.shaft.com/citrix/storeweb", 
  "Resource=0", 
  "RecContentType=text/html", 
  "Referer=", 
  "Snapshot=t10.inf", 
  "Mode=HTML", 
  EXTRARES, 
  "Url=../Citrix/StoreWeb/receiver/js/external/velocity.min_B218502A82F66680.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/js/external/hammer.v2.0.8.min_F699A1E56189259A.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/js/external/jquery.dotdotdot.min_08EE54CBA886AD0A.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/js/external/slick.min_FEB62CC230E2BA2A.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/js/ctxs.core.min_913780ECE5947BE4.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/js/ctxs.webui.min_41CC5860D625BCD9.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/custom/style.css", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/css/ctxs.large-ui.min_647DF07BE00D295E.css", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/folder_template_C13BB96DEBC9F30F.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/actionSprite_531B7A6FF85CA98E.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/CitrixReceiver_WebScreen_CBE548FB8FEE049E.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/common/ReceiverFullScreenBackground_46E559C0E6B5A27B.jpg", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/custom/script.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/custom/strings.en.js", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/viewSprite_B2F322BDCB824FAF.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/common/authspinner_B0BCD339560CA593.gif", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/CitrixStoreFront_auth_14B96BFF2B0A6FF8.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/spinner_white_auth_button_53FD5A337A529DA7.gif", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/common/icon_loading_9A0623127A028FEB.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/Resources/Icon/L0NpdHJpeC9TdG9yZS9yZXNvdXJjZXMvdjIvU213ek1WTXJNVXBtYjI1MFowTjZZa2N5UkZwNmIxUlBhMDQ0UFEtLS9pbWFnZQ--?size=128", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/search_close_BC5A22358E58905F.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/CitrixReceiverLogo_Home_5C24BCEC5A182425.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/spinner_5CF0D1C8A76AAC8E.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/ico_search_E84E3D63D821F80D.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  "Url=../Citrix/StoreWeb/receiver/images/1x/ico_desktop_ready_482FD91B201F2A55.png", "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", ENDITEM, 
  LAST);

 web_add_auto_header("X-Citrix-IsUsingHTTPS", 
  "No");

 web_add_auto_header("X-Requested-With", 
  "XMLHttpRequest");

/*Correlation comment: Automatic rules - Do not change!  
Original value='CAB598DC40F9DF729BA594970033E077' 
Name ='CitrixXenApp_CsrfToken' 
Type ='Rule' 
AppName ='Citrix_XenApp' 
RuleName ='CsrfToken'*/
 web_reg_save_param_ex(
  "ParamName=CitrixXenApp_CsrfToken",
  "LB/IC=CsrfToken=",
  "RB/IC=;",
  SEARCH_FILTERS,
  "Scope=Cookies",
  "RequestUrl=*/Configuration*",
  LAST);

 web_custom_request("Configuration", 
  "URL=http://ctx.shaft.com/Citrix/StoreWeb/Home/Configuration", 
  "Method=POST", 
  "Resource=0", 
  "RecContentType=application/xml", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t11.inf", 
  "Mode=HTML", 
  "EncType=", 
  LAST);

 web_add_cookie("CtxsPluginAssistantState=Done; DOMAIN=ctx.shaft.com");

 web_add_auto_header("Csrf-Token",
  "{CitrixXenApp_CsrfToken}");

 web_submit_data("List", 
  "Action=http://ctx.shaft.com/Citrix/StoreWeb/Resources/List", 
  "Method=POST", 
  "RecContentType=text/plain", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t12.inf", 
  "Mode=HTML", 
  ITEMDATA, 
  "Name=format", "Value=json", ENDITEM, 
  "Name=resourceDetails", "Value=Default", ENDITEM, 
  LAST);

 web_custom_request("GetAuthMethods", 
  "URL=http://ctx.shaft.com/Citrix/StoreWeb/Authentication/GetAuthMethods", 
  "Method=POST", 
  "Resource=0", 
  "RecContentType=application/xml", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t13.inf", 
  "Mode=HTML", 
  "EncType=", 
  LAST);
//
// web_revert_auto_header("Csrf-Token");

// web_revert_auto_header("X-Citrix-IsUsingHTTPS");
//
// web_revert_auto_header("X-Requested-With");
//
// web_add_auto_header("Csrf-Token",
//  "{CitrixXenApp_CsrfToken}");

 web_custom_request("Login", 
  "URL=http://ctx.shaft.com/Citrix/StoreWeb/ExplicitAuth/Login", 
  "Method=POST", 
  "Resource=0", 
  "RecContentType=application/vnd.citrix.authenticateresponse-1+xml", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t14.inf", 
  "Mode=HTML", 
  "EncType=", 
  EXTRARES, 
  "Url=https://www.bing.com/favicon.ico", "Referer=", ENDITEM, 
  LAST);

 web_set_sockets_option("SSL_VERSION", "TLS1.2");

 web_add_auto_header("X-Citrix-IsUsingHTTPS", 
  "No");

 web_add_auto_header("X-Requested-With", 
  "XMLHttpRequest");

 web_submit_data("LoginAttempt", 
  "Action=http://ctx.shaft.com/Citrix/StoreWeb/ExplicitAuth/LoginAttempt", 
  "Method=POST", 
  "RecContentType=application/xml", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t15.inf", 
  "Mode=HTML", 
  "EncodeAtSign=YES", 
  ITEMDATA, 
  "Name=username", "Value=shaft\\shaftctx20", ENDITEM, 
  "Name=password", "Value=Sh@ft123", ENDITEM, 
  "Name=saveCredentials", "Value=false", ENDITEM, 
  "Name=loginBtn", "Value=Log On", ENDITEM, 
  "Name=StateContext", "Value=", ENDITEM, 
  LAST);

 web_submit_data("List_2", 
  "Action=http://ctx.shaft.com/Citrix/StoreWeb/Resources/List", 
  "Method=POST", 
  "RecContentType=application/json", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t16.inf", 
  "Mode=HTML", 
  ITEMDATA, 
  "Name=format", "Value=json", ENDITEM, 
  "Name=resourceDetails", "Value=Default", ENDITEM, 
  LAST);

 web_custom_request("GetUserName", 
  "URL=http://ctx.shaft.com/Citrix/StoreWeb/Authentication/GetUserName", 
  "Method=POST", 
  "Resource=0", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t17.inf", 
  "Mode=HTML", 
  "EncType=", 
  LAST);

 web_add_cookie("SRCHD=AF=NOFORM; DOMAIN=iecvlist.microsoft.com");

 web_add_cookie("SRCHUID=V=2&GUID=AA30ACF476A441C3A0D8D63E620AED81&dmnchg=1; DOMAIN=iecvlist.microsoft.com");

 web_add_cookie("SRCHUSR=DOB=20181207; DOMAIN=iecvlist.microsoft.com");

 web_custom_request("AllowSelfServiceAccountManagement", 
  "URL=http://ctx.shaft.com/Citrix/StoreWeb/ExplicitAuth/AllowSelfServiceAccountManagement", 
  "Method=POST", 
  "Resource=0", 
  "RecContentType=application/xml", 
  "Referer=http://ctx.shaft.com/Citrix/StoreWeb/", 
  "Snapshot=t18.inf", 
  "Mode=HTML", 
  "EncType=", 
  EXTRARES, 
  "Url=https://iecvlist.microsoft.com/IE11/1479242656000/iecompatviewlist.xml", "Referer=", ENDITEM, 
  LAST);

 ctrx_nfuse_connect("http://ctx.shaft.com/Citrix/StoreWeb/Resources/LaunchIca/U2hhZnQuS1dIb3RlbA--.ica?CsrfToken={CitrixXenApp_CsrfToken}&IsUsingHttps=No&launchId=1544174851766", CTRX_LAST);

 ctrx_wait_for_event("LOGON", CTRX_LAST);

 lr_think_time(4);

 ctrx_sync_on_window("User login", ACTIVATE, 194, 175, 412, 248, "snapshot2101", CTRX_LAST);

 ctrx_type("admin", "", CTRX_LAST);

 ctrx_key("TAB_KEY", 0, "", CTRX_LAST);

 ctrx_type("S", "", CTRX_LAST);

// ctrx_key("NO_KEY", MODIF_SHIFT, "", CTRX_LAST);

 lr_think_time(7);

 ctrx_key("BACKSPACE_KEY", 0, "", CTRX_LAST);

// ctrx_type("S", "", CTRX_LAST);

// ctrx_key("NO_KEY", MODIF_SHIFT, "", CTRX_LAST);

 ctrx_type("Sh@ft123", "", CTRX_LAST);

 ctrx_key("TAB_KEY", 0, "", CTRX_LAST);

 ctrx_key("TAB_KEY", 0, "", CTRX_LAST);

 ctrx_key("ENTER_KEY", 0, "", CTRX_LAST);

 lr_think_time(5);

 ctrx_sync_on_window("KWHotel Free (0.47.108) - [Calendar]", ACTIVATE, 0, 0, 801, 601, "snapshot2110", CTRX_LAST);

 
// ctrx_sync_on_bitmap(222, 56, 37, 37, "39e4123d16312e3980861cf8fea72dc8", CTRX_LAST);
 
 ctrx_get_window_name(window_name, CTRX_LAST);

if(strcmp(window_name, "KWHotel Free (0.47.108) - [Calendar]")==0)
{
//     ctrx_get_window_position(window_name, 0, 0, 801, 601, CTRX_LAST);
lr_output_message("the window is available : pass",window_name);
}
 else
 {
  lr_output_message("the window is not available : fail",window_name);
 }
 
  
// ctrx_sync_on_bitmap(222, 56, 37, 37, "39e4123d16312e3980861cf8fea72dc8", CTRX_LAST);

 ctrx_get_bitmap_value(222, 56, 37, 37, buffer, CTRX_LAST );
 
 if(strcmp(buffer, "39e4123d16312e3980861cf8fea72dc8")==0)
{
//     ctrx_get_window_position(window_name, 0, 0, 801, 601, CTRX_LAST);
lr_output_message("the image is available : pass",buffer);
}
 else
 {
  lr_output_message("the image is not available : fail",buffer);
 } 
  
 ctrx_get_text("About Notepad", 264, 68, 44, 13, "snapshot8", text_buffer, CONTINUE_ON_ERROR,CTRX_LAST );
  
  text=ctrx_sync_on_text_ocr(264, 68, 44, 13, "Services", "NULL=snapshot_1", CONTINUE_ON_ERROR, CTRX_LAST);

  if(strcmp(text)==0)
  {
  lr_output_message("the text is available : pass",text);
  }
 else
  {
  lr_output_message("the text is not available : fail",text);
  } 
   
    
    
  
 ctrx_key("t", MODIF_ALT, "", CTRX_LAST);


 ctrx_key("DOWN_ARROW_KEY", 0, "", CTRX_LAST);

 ctrx_key("ENTER_KEY", 0, "", CTRX_LAST);

 return 0;
}

1 comment:

  1. Where can i download(link) citrix agent and install in citrix server to capture dynamics values or text or drop down values ?

    ReplyDelete