Help Admin Adding a monitor Advanced Web Script Editing in Web Transaction (Browser) Monitor

Advanced Web Script Editing in Web Transaction (Browser) Monitor

The Web Transaction (Browser) monitor records and saves the user actions in a web script. These powerful scripts act as a means to measure the web performance via a real browser simulation. The scripts describe actions like mouse clicks, validations, navigation and more. You can update the existing web script actions using our inline client web script editor. This advanced web scripting tool lets you manipulate your recorded actions and update your Web Transaction (Browser) Monitor configuration without having to rerecord the transaction using a recorder. By default,  the Web Transaction (Browser) uses a feature called Intelligent Playback to identify the attribute level changes of the HTML element; and auto updates your recorded scripts. However, if you want to stop intelligent playback, enter and execute command update_intelligent_play_candidates("false") in your advanced web script editor.

Following are the various commands that are used to update the web script. Please pay attention to the format in which these expressions are updated in the editor.

  • Every parameter in a command is mandatory. However, for the parameter DISPLAY_NAME, you can pass an empty value between double quotes while maintaining the defined format for each command.
  • If you are attempting to perform a click that would initiate a download, you will see a pop-up "File download is not supported". Please note that the web transaction monitor does not support a file download action and you will need to close the pop-up box to proceed.

Web Script Commands

1. Create a step.

Command:begin_step("<STEP_NAME>","<STEP_URL>")

Example:
begin_step("Step 1: Loading http://www.vtitan.com","http://www.vtitan.com")
begin_step("Step 2: Click CORPORATE","http://www.vtitan.com/corporate.html").

If the attribute Ignore the step status is set to true, then you'll be able to proceed to the next step even if the current step fails. The transaction can move to the next step only if the error does not affect the progress of the transaction. If it is false, the transaction process will be stopped when the step fails. For example:

begin_step("Step 1: Loading http://www.vtitan.com", "http://www.vtitan.com", "true")
begin_step("Step 2: Loading http://www.vtitan.com", "http://www.vtitan.com", "false")

2. Open a web page.

Command:load_page("<OPEN_URL>")

Example:
load_page("https://www.vtitan.com/coporate.html")

OPEN_URL = Base_URL to start a transaction

3. Wait for the page to load until you receive HTTP status code 200.

Command: wait_for_page_to_load()
This has to be included after every action (i.e., which involves URL change)

4. Verify the page status.

Command: verify_page_load_status()
This has to be included after every action (i.e., which involves URL change)

5. Specify authentication credentials.

Command: set_auth_credentials("<DOMAIN>","<USER_NAME>","<PASSWORD>")

Example:
set_auth_credentials("vtitan.com","xyz","123")
  • DISPLAY_NAME for internal use
  • INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter
  • Syntax:

    #SEP#id=<ELEMENT_ID>#SEP#name=<ELEMENT_NAME>#SEP#linktext=<ELEMENT_LINKTEXT>#SEP#css=<ELEMENT_CSS>#xpath=<ELEMENT_XPATH_1>#XPATH#<ELEMENT_XPATH_2>#XPATH#<ELEMENT_XPATH_3>#XPATH##SEP#

6. Click on an element.

Command: click_element_by_id/name/linktext/css/xpath("<ELEMENT_ID/NAME/LINKTEXT/CSS/XPATH>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
click_element_by_id("corporate","disp_corp","#SEP#id=corporate#SEP#name=corporate#SEP#linktext=CORPORATE#SEP
#css=#topmenu>li>a#SEP#xpath=//a[contains(text(),'CORPORATE')]#XPATH#//ul[@id='topmenus']/li/a#XPATH#
//a[contains(@href, 'corporate.html')]#XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")
  • ELEMENT_ID should be given as the first parameter in case of click_element_by_id, ELEMENT_NAME in case of click_element_by_name and respectively for other properties.
  • INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

7. Double click on an element.

Command: double_click_by_id/name/linktext/css/xpath("<ELEMENT_ID/NAME/LINKTEXT/CSS/XPATH>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
double_click_by_id("corporate","disp_corp","#SEP#id=corporate#SEP#name=corporate#SEP#linktext=CORPORATE#SEP
#css=#topmenu>li>a#SEP#xpath=//a[contains(text(),'CORPORATE')]#XPATH#//ul[@id='topmenus']/li/a#XPATH#//a[contains
(@href, 'corporate.html')]#XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")
  • ELEMENT_ID should be given as first parameter in case of double_click_by_id, ELEMENT_NAME in case of double_click_by_name and respectively for other properties.
  • INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

8. Mouseover an element.

Command: mouse_over_by_id/name/linktext/css/xpath("<ELEMENT_ID/NAME/LINKTEXT/CSS/XPATH>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
mouse_over_by_id("corporate","disp_corp","#SEP#id=corporate#SEP#name=corporate#SEP#linktext=CORPORATE#SEP#
css=#topmenu>li>a#SEP#xpath=//a[contains(text(),'CORPORATE')]#XPATH#//ul[@id='topmenus']/li/a#XPATH#
//a[contains(@href, 'corporate.html')]#XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")
  • ELEMENT_ID should be given as the first parameter in case of mouse_over_by_id, ELEMENT_NAME in case of mouse_over_by_name and respectively for other properties. Both click element and mouseover takes the same parameters; only the function name changes.
  • INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

9. Enter value inside an input field.

Command: set_text_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH>","<TEXT_VALUE>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
set_text_by_id("username","xyzuser","disp_username,"#SEP#id=username#SEP#name=username#SEP#css=
#topmenu>li>input[1]#SEP#xpath=//ul[@id='topmenus']/li/input[1]#XPATH#//input[1]#XPATH
#//tr[2]/td/ul/li/input[1]#XPATH##SEP#")
  • ELEMENT_ID should be given as the first parameter in case of set_text_by_id, ELEMENT_NAME in case of set_text_by_name and respectively for other properties.
  • TEXT_VALUE - value to be entered in the text field
  • INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

10. Enter value inside an input field.

Command: type_keys_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH>","<TEXT_VALUE>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
type_keys_by_id("username","xyzuser","disp_username,"#SEP#id=username#SEP#name=username#SEP#css=#
topmenu>li>input[1]#SEP#xpath=//ul[@id='topmenus']/li/input[1]#XPATH#//input[1]#XPATH
#//tr[2]/td/ul/li/input[1]#XPATH##SEP#")
  • ELEMENT_ID should be given as the first parameter in case of type_keys_by_id, ELEMENT_NAME in case of type_keys_by_name and respectively for other properties.
  • TEXT_VALUE - the value that needs to be entered in text field
  • INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

11. Add password.

Command: set_password_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH>","<PASSWORD>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
set_password_by_id(password,"123password","disp_password,"#SEP#id=password#SEP#name=password#SEP
#css=#topmenu>li>input[2]#SEP#xpath=//ul[@id='topmenus']/li/input[2]#XPATH#//input[2]#XPATH
#//tr[2]/td/ul/li/input[2]#XPATH##SEP#")
  • ELEMENT_ID should be given as the first parameter in case of click_element_by_id, ELEMENT_NAME in case of click_element_by_name and respectively for other properties.
  • Password - the password that needs to be entered in the password field
  • INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

12. Select an entry from select menu.

a) Select by innerHTML.

Command: select_text_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH>","<TEXT>","<DISPLAY_NAME>","<"INTELLIGENT_PLAY_CANDIDATES">)

Example:
select_text_by_id("state","california","disp_state","#SEP#id=id_state#SEP#name=name_state#SEP#css=#topmenu>li>select[3]
#SEP#xpath=//ul[@id='topmenus']/li/select[3]#XPATH#//select[3]#XPATH#//li/select[3]#XPATH##SEP#
INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

b) Select by value.

Command: select_value_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH>","<VALUE>","<DISPLAY_NAME>","<"INTELLIGENT_PLAY_CANDIDATES">)

Example:
select_value_by_id("state","California-US","disp_state","#SEP#id=id_state#SEP#name=name_state#SEP#css=#topmenu>li>select[3]#SEP
#xpath=//ul[@id='topmenus']/li/select[3]#XPATH#//select[3]#XPATH#//li/select[3]#XPATH##SEP#
INTELLIGENT_PLAY_CANDIDATES - INTELLIGENT_PLAY_CANDIDATES contains identifiers of an element and can be used to access a particular element. If an identifier fails, the element can still be accessed using the remaining available identifiers. Different types of element identifiers should be separated by the #SEP# delimiter and different XPath's should be separated by the #XPATH# delimiter

c) Select by index. 

Command: select_index_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH>","<INDEX>","<DISPLAY_NAME>","<"INTELLIGENT_PLAY_CANDIDATES">)

Example:
select_index_by_id("state","3","disp_state","#SEP#id=id_state#SEP#name=name_state#SEP#css=#topmenu>li>select[3]
#SEP#xpath=//ul[@id='topmenus']/li/select[3]#XPATH#//select[3]#XPATH#//li/select[3]#XPATH##SEP#
index starts from 0.

13. Uncheck the check box.

Command: clear_selection_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH>","<DISPLAY_NAME>")

Example:
clear_selection_by_id("cartype","disp_name")

14. Select the check box.

Command: check_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH">,"<DISPLAY_NAME>","<INTELLEGENT_PLAY_CANDIDATES>")

Example:
check_by_id("volvo","car_type","#SEP#id=volvo#SEP#name=volvo#SEP#css=#topmenu>li>input[1]#SEP
#xpath=//ul[@id='topmenus']/li/input[1]#XPATH#//input[1]#XPATH#//tr[2]/td/ul/li/input[1]#XPATH##SEP#

15. Unselect the check box.

Command: uncheck_by_id/name/css/xpath("<ELEMENT_ID/NAME/CSS/XPATH">,"<DISPLAY_NAME>","<INTELLEGENT_PLAY_CANDIDATES>")

Example:
uncheck_by_id("volvo","car_type","#SEP#id=volvo#SEP#name=volvo#SEP#css=#topmenu>li>input[1]
#SEP#xpath=//ul[@id='topmenus']/li/input[1]#XPATH#//input[1]#XPATH#//tr[2]/td/ul/li/input[1]#XPATH##SEP#

16. Select a frame before performing an action.

Command:
select_frame_by_id/name/index/src("<FRAME_ID/NAME/INDEX/SRC>")
select_frame("relative=up") - for moving back to top frame from the specific frame.

Example:
select_frame_by_id("topframe")
use select_frame("relative=up") after performing any action inside child frame

17. Select a parent window.

Command:
selectMainWindow()

18. Select a window before performing any action..

Command: select_window_by_name/title/index("<WINDOW_NAME/TITLE/INDEX>")

Example:
select_window_by_name("contentWindow")

19. Close the window.

Command:
close_window_by_name/title/index("<WINDOW_NAME/TITLE/INDEX>")
close_window() - closes the last selected window

Example:
close_window_by_name("contentWindow")
WINDOW_NAME/TITLE/INDEX used here will be the one that you'd have used in select_window.

20. Pause for a specific time.

Command: wait("<TIME_IN_MILLISECONDS>")

Example:
wait("5000")
Time should be specified in milliseconds.

21. Verify the presence of text on a webpage.

Command: assert_text_present("\"<TEXT_1>\" \"<TEXT_2>\"", "true")

Example:
assert_text_present("CORPORATE","true")
assert_text_present("\"CORPORATE\"  \"PRODUCTS\"","true")
For verifying presence of multiple text in a webpage, specify each text in double quotes and escape double quotes (\"CORPORATE\"). If you've specified it as "true," the playback of transaction steps would not stop even during a failure. However, if you've specified it as "false", the playback would stop as and when the failure gets reported.

22. Verify the absence of text on a web page.

Command: assert_text_not_present("\"<TEXT_1>\" \"<TEXT_2>\"", "true")

Example:
assert_text_not_present("error","true")
assert_text_not_present("\"error\"  \"warning\"","true")
For verifying absence of multiple text in a webpage, specify each text in double quotes and escape double quotes (\"error\"). If you've specified it as "true," the playback of transaction steps would not stop even during a failure. However, if you've specified it as "false", the playback would stop as and when the failure gets reported.

23. Check the title of the current web page.

Command: assert_title("<TITLE>")

Example:
assert_title("vTitan | Safer Health for everyone")

24. Specify confirmation of alert box.

Command: assert_confirmation("<ALERT_BOX_MESSAGE>")

Example:
assert_confirmation("Do you want to log out?")

25. Confirm alert box.

Command: assert_alert("<ALERT_BOX_MESSAGE>")

Example:
assert_alert("Do you want to log out?")

26. Get the text to be used in the prompt box.

Command: answer_on_next_prompt("<PROMPT_TEXT>")

Example:
answer_on_next_prompt("XYZ")

27. Check the prompt message.

Command: assert_prompt("<PROMPT_MESSAGE">)

Example:
assert_prompt("Please enter your name")

28. Ignore modal dialogue.

Command: ignore_modal_dialog("true")

29. Verify your URL.

Command: assert_location("<URL>","true")

Example:
assert_location("http://vtitan.com/corporate.html","true")
For verifying the current URL loaded, specify it in double quotes(\"URL\"). If you've specified it as "true," the playback of transaction steps would not stop even during a failure. However, if you've specified it as "false", the playback would stop as and when the failure gets reported.

30.Wait for an element to load.

Note: This may not work for AJAX calls.

Command: wait_for_element_presence("identifier","identifier_value",timeout)


Example:

wait_for_element_presence("id","country_code","40")

31.Wait for a page to load.

Command: set_page_load_timeout("45")

Note:This will add an extra wait time of 15 seconds over the default value.

Example: Check the status of Vtitan.com
Step 1:
Load the url (http://www.vtitan.com)
Check for the keyword not present "error"

Step 2:
Click on CORPORATE
Check for the keyword "PRODUCTS"

32. Open a new URL of the same domain.

Example: navigate_to("www.vtitan.com/products.html")

Note:This will open the page vtitan.com/products without performing any click action.

33. Verify the presence of an element keyword on the webpage.

Command: assert_element_keyword_check("identifier","identifier_value","value" )

Note: The identifier could be anything such as an id, name, css or xpath.

Example: assert_element_keyword_check("id","state","California")

34. Verify the presence of an element  on the webpage.

Command: assert_element_check("identifier","identifier_value")

Note: The identifier could be anything such as an id, name, css or xpath.

Example: assert_element_check("id","state")

35. Wait for an element to be visible.

Note: This may not work for AJAX calls.
Command: wait_for_element_visibility("identifier","identifier_value",timeout)

Example: wait_for_element_visibility("id","country_code","40")
When the content/links change or are dynamic, you should use static xpath (Position based xpath). Site24x7 captures xpaths too, but we have to remove other attributes and keep the Position based xpath alone.

Action with dynamic identifiers :

click_element_by_id("az1234","disp_corp","#SEP#id=az1234#SEP#name=az1235#SEP##SEP#linktext=test123
#SEP#xpath=//a[contains(text(),'test123')]#XPATH#xpath=//ul [@id='topmenus1234']/li/a#XPATH#//a
[contains(@href,'tesing123.html')] #XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")

After removing the dynamic identifier and the action with the position based xpath this is what you'll obtain :
click_element_by_xpath("//tr[2]/td/ul/li/a","disp_corp","#SEP#xpath=//tr[2]/td/ul/li/a#XPATH##SEP#")

Also in some cases if it is not possible to obtain the static position based xpaths while recording, then you can create it manually.

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help Admin Adding a monitor Advanced Web Script Editing in Web Transaction (Browser) Monitor