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.
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").
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.
Example:
load_page("https://www.vtitan.com/coporate.html")
3. Wait for the page to load until you receive HTTP status code 200.
4. Verify the page status.
5. Specify authentication credentials.
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.
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.
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.
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.
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.
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.
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.
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#
b) Select by value.
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#
c) Select by index.
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#
13. Uncheck the check box.
Example:
clear_selection_by_id("cartype","disp_name")
14. Select the check box.
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.
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.
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")
17. Select a parent window.
selectMainWindow()
18. Select a window before performing any action..
Example:
select_window_by_name("contentWindow")
19. Close the window.
close_window_by_name/title/index("<WINDOW_NAME/TITLE/INDEX>")
close_window() - closes the last selected window
Example:
close_window_by_name("contentWindow")
20. Pause for a specific time.
Example:
wait("5000")
21. Verify the presence of text on a webpage.
Example:
assert_text_present("CORPORATE","true")
assert_text_present("\"CORPORATE\" \"PRODUCTS\"","true")
22. Verify the absence of text on a web page.
Example:
assert_text_not_present("error","true")
assert_text_not_present("\"error\" \"warning\"","true")
23. Check the title of the current web page.
Example:
assert_title("vTitan | Safer Health for everyone")
24. Specify confirmation of alert box.
Example:
assert_confirmation("Do you want to log out?")
25. Confirm alert box.
Example:
assert_alert("Do you want to log out?")
26. Get the text to be used in the prompt box.
Example:
answer_on_next_prompt("XYZ")
27. Check the prompt message.
Example:
assert_prompt("Please enter your name")
28. Ignore modal dialogue.
29. Verify your URL.
Example:
assert_location("http://vtitan.com/corporate.html","true")
30.Wait for an element to load.
Note: This may not work for AJAX calls.
Example:
wait_for_element_presence("id","country_code","40")
31.Wait for a page to load.
Note:This will add an extra wait time of 15 seconds over the default value.
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.
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.
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.
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.
Example: wait_for_element_visibility("id","country_code","40")
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.