8.3 - Test Designer JS Commands Reference

Test Designer JS Commands Reference

General Functions

<div id="bkmrk-if-you-cannot-find-t"> <div> <h3 id="bkmrk--1"> </h3> <p class="note">If you cannot find the function in the Test Designer IDE, then use custom JS actions.<br><img src="../../../Resources/Images/Technical%20Reference/TestDesignerJSCommands_01.png" alt="TestDesignerJSCommands_01.png"></p> </div> </div> <h3 id="bkmrk-_addnetworklibrary-%3D">_addNetworkLibrary = addNetworkLibrary</h3> <p id="bkmrk-parameters%3A-filepath">Parameters: filepath<br>Description: adds a network library with HTTP extractions and validaations to the script execution<br>Example:</p> <blockquote id="bkmrk-addnetworklibrary%28%22%7B"> <p><code>addNetworkLibrary("{ds}/Favorites.stags")</code>;</p> </blockquote> <h3 id="bkmrk-_addsmarttagslibrary">_addSmartTagsLibrary = addSmartTagsLibrary</h3> <p id="bkmrk-parameters%3A-filepath-1">Parameters: filepath<br>Description: adds a smarttags library enabling the usage of the defined smartags within the test designer script.<br>Example:</p> <blockquote id="bkmrk-addsmarttagslibrary%28"> <p><code>addSmartTagsLibrary("{ds}/demositeSmartTags.netx");</code> <br><code>navigateTo("</code>https://demosite.appvance.com<code>")</code>;</p> </blockquote> <h3 id="bkmrk-_alert-%3D-alert"><span>_alert </span>= alert</h3> <p id="bkmrk-parameters%3A-messaged">Parameters: message<br>Description: <span style="color:rgb(0,0,0);">Alerts the message on the browser. This allows a very handy, interactive way of debugging scripts. </span><br>Example:</p> <blockquote id="bkmrk-_setcompatibility%28tr"> <p><code>_setCompatibility(true)</code> <br><code>_navigateTo("</code>http://sahitest.com/<code>");</code><br><code>_click(_link("demo"));</code><br><code>_navigateTo("</code>http://sahitest.com/demo/formTest.htm<code>");</code><br><code>_wait(1000);</code><br><code>assertEqual("object",_lastAlert())</code><br><code>_wait(1000)</code><br><code>_clearLastAlert()</code><br><code>assertEqual("",_lastAlert())</code></p> </blockquote> <h3 id="bkmrk-_clearlastalert-%3D-cl">_clearLastAlert = clearLastAlert</h3> <p id="bkmrk-description%3A-content">Description: <span style="color:rgb(0,0,0);">contents of the last pop up is cleared</span><br>Example:</p> <blockquote id="bkmrk-clearlastalert%28%29"> <p><code>clearLastAlert()</code> </p> </blockquote> <h3 id="bkmrk-_click-%3D-click">_click = click</h3> <p id="bkmrk-parameters%3A-target%2C-">Parameters: target, [options]<br>Description: Executes a click the target element. Options parameter can be "CTRL", "SHIFT", "ALT" or "META", or combinations like "CTRL|SHIFT"<br>Examples:</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F"> <p><code>navigateTo("</code>https://demosite.appvance.com<code>")</code><br><code>click(link("Mugs"))</code><br><code>click(link("Bags"), "CTRL")</code></p> </blockquote> <h3 id="bkmrk-_clickxy-%3D-clickxy">_clickXY = clickXY</h3> <p id="bkmrk-parameters%3A-target%2C--1">Parameters: target, xy, [options]<br>Description:<br>Example: <span style="color:rgb(0,0,0);">Simulates a click event at the point (x,y).</span></p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-1"> <p><code>navigateTo("</code>https://www.apple.com<code>")</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"))</code><br><code>clickXY(link("ac-gn-link ac-gn-link-tv"),"30,10")</code></p> </blockquote> <h3 id="bkmrk-_cookie-%3D-cookie">_cookie = cookie</h3> <p id="bkmrk-parameters%3A-cookiena">Parameters: cookieName<br>Description: returns the value of a browser cookie.<br>Example:</p> <blockquote id="bkmrk-_navigateto%28%22http%3A%2F%2F"> <p><code>_navigateTo("</code>http://sahitest.com/<code>")</code><br><code>_createCookie("DS3Cookie","Ready")</code><br><code>_click(_link("demo"))</code><br><code>var myCookie = _cookie("DS3Cookie")</code><br><code>_assertEqual(myCookie,"Ready")</code></p> </blockquote> <h3 id="bkmrk-_createcookie-%3D-crea">_createCookie = createCookie</h3> <p id="bkmrk-parameters%3A-cookiena-1">Parameters: cookieName, cookieValue<br>Description: creates a cookie in the current browser session.<br>See Also: deleteCookie, cookie.<br>Example:</p> <blockquote id="bkmrk-_navigateto%28%22http%3A%2F%2F-1"> <p><code>_navigateTo("</code>http://sahitest.com/<code>")</code><br><code>_createCookie("DS3Cookie","Ready")</code><br><code>_click(_link("demo"))</code><br><code>var myCookie = _cookie("DS3Cookie")</code><br><code>_assertEqual(myCookie,"Ready")</code></p> </blockquote> <h3 id="bkmrk-_deletecookie-%3D-dele">_deleteCookie = deleteCookie</h3> <p id="bkmrk-parameters%3A-cookiena-2">Parameters: cookieName<br>Description: deletes a cookie from the current browser session.<br>Example:</p> <blockquote id="bkmrk-_deletecookie%28%22ds3co"> <p><code>_deleteCookie("DS3Cookie")</code> </p> </blockquote> <h3 id="bkmrk-_doubleclick-%3D-doubl">_doubleClick = doubleClick</h3> <p id="bkmrk-parameters%3A-target%2C--2">Parameters: target, [options]<br>Description: simulates the double clicks on the given target element.</p> <p id="bkmrk-example%3A">Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs"> <p><code>navigateTo("</code>http://sahitest.com/<code>")</code><br><code>click(link("/demo"))</code><br><code>click(link("clicks.htm"))</code><br><code>click(button("dbl click me"))</code><br><code>doubleClick(button("dbl click me"))</code><br><code>click(button("click me"))</code></p> </blockquote> <h3 id="bkmrk-_doubleclickxy-%3D-dou">_doubleClickXY = doubleClickXY</h3> <p id="bkmrk-parameters%3A-target%2C--3">Parameters: target, xy, [options]<br>Description: <span style="color:rgb(0,0,0);">Simulates a double click event at the point (x,y).</span><br>Example: <br></p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-2"> <p><code>navigateTo("</code>https://www.apple.com<code>")</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"))</code><br><code>doubleclickXY(link("ac-gn-link ac-gn-link-tv"),"30,10")</code></p> </blockquote> <h3 id="bkmrk-_drag-%3D-drag">_drag = drag</h3> <p id="bkmrk-parameters%3A-target%2C--4">Parameters: target, options<br>Description: <span style="color:rgb(0,0,0);">Simulates a mouse drag action</span><br><span style="color:rgb(0,0,0);">Example: </span><br><span style="color:rgb(0,0,0);">See example for _drop below.</span><br></p> <h3 id="bkmrk-_drop-%3D-drop">_drop = drop</h3> <p id="bkmrk-parameters%3A-target%2C--5">Parameters: target, xy<br>Description: <span style="color:rgb(0,0,0);">Simulates the drop action in a drag and drop operation</span><br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fj"> <p><code>navigateTo("</code>http://jqueryui.com/draggable/<code>");</code><br><code>click(link("/resources/demos/draggable/snap-to.html"));</code><br><code>click(div("snaptarget"));</code><br><code>click(div("draggable2"));</code><br><code>drag(div("draggable2"),);</code><br><code>drop(div("snaptarget"),"40,20");</code><br><code>click(byXPath('//*[text()="I only snap to the outer edges of the big box"]'));</code><br><code>click(paragraph("I snap to a 80 x 80 grid"));</code><br><code>click(paragraph("I snap to a 20 x 20 grid"));</code></p> </blockquote> <h3 id="bkmrk-_eval">_eval</h3> <p id="bkmrk-parameters%3A-data-%28ex">Parameters: data (expects native array)<br>Description: Evaluates the provided javascript code in the browser. The function can provide return data as well as execute some action.</p> <p id="bkmrk-_eval-example-1%3A">_eval example 1:</p> <blockquote id="bkmrk-function-name%28%29-%7B-va"> <p><code> function name() { </code> <br><code> var anchor = _eval("ds$('a')");</code> <br><code> log(typeof anchor);</code> <br><code> log("lngth:" + anchor.length);</code> <br><code> for(var i =0;i&lt;10;i++) {</code> <br><code> var href = getAttribute(anchor[i],"href");</code> <br><code> log("href:" + href);</code> <br><code> } </code> <br><code> }</code> <br><code> navigateTo("</code>https://www.w3schools.com<code>");</code><br><code> name();</code></p> </blockquote> <p id="bkmrk-_eval-example-2%3A">_eval example 2:</p> <blockquote id="bkmrk-_navigateto%28%22https%3A%2F"> <p><code>_navigateTo("</code>https://www.apple.com<code>");</code><br><code>_log("typeof "+typeof _eval("(function(){})();"));</code><br><code>_log( _eval("(function(){return null;})();"));</code><br><code>_eval("ds$('html, body').scrollTop(ds$(document).height())");</code></p> </blockquote> <p id="bkmrk-_eval-example-3%3A">_eval example 3:</p> <blockquote id="bkmrk-var-collection-%3D-_ev"> <p><code>var collection = _eval("ds$('.space-program-detail').not('.hideProgram').find('.program-name')");</code> <br><code>log(collection.length);</code> <br><code>var data = _getLength('.space-program-detail');</code> <br><code>log(data);</code> </p> </blockquote> <p id="bkmrk-_eval-example-4%3A">_eval example 4:</p> <blockquote id="bkmrk-_eval%28%22ds%24%28%27html%2C-bo"> <p><code>_eval("ds$('html, body').scrollTop(ds$(document).height())");</code> <br><code>_wait(4000);</code> <br><code>var data1 = _eval("Math.round(ds$(window).scrollTop())");</code> <br><code>log(data1);</code> <br><code>var data2 = _eval("ds$(window).height()");</code> <br><code>_log(data2);</code> <br><code>var data4 = data1 + data2;</code> <br><code>_log(data4);</code> <br><code>var data3 = _eval("ds$(document).height()");</code> <br><code>_log(data3);</code> <br><code>var end = _eval("Math.round(ds$(window).scrollTop())+ ds$(window).height() == ds$(document).height()");</code> <br><code>_log(end);</code> <br><code>if(end == true) {</code> <br><code> _log("scroll bottom is reached");</code> <br><code>}</code> </p> </blockquote> <h3 id="bkmrk-_formsubmit-%3D-formsu">_formSubmit = formSubmit</h3> <p id="bkmrk-parameters%3A-targetde">Parameters: target<br>Description: <br>FormSubmit API is used to Simulate the ENTER key action by the user by Submitting the form of the application. We can also use Native key actions however the drawback of this is that we cannot use this for Performance test and also the browser needs to be in focus all the time<br>To overcome the drawback of Native key Events we can use this API as this works fine even if the browser is not in focus and also can be used in Performance tests</p> <p id="bkmrk-example%3A-1">Example:</p> <blockquote id="bkmrk-_navigateto%28%22website"> <p><code>_navigateTo("website URL");</code> <br><code>_formSubmit(_form("partlookupform"));</code> <br><code>_wait(3000);</code> <br><code>_assertContainsText("Invalid Query",_div("custdialog"));</code> <br><code>_click(_span("OK"));</code> </p> </blockquote> <h3 id="bkmrk-_focus-%3D-focus">_focus = focus</h3> <p id="bkmrk-parameters%3A-valuedes">Parameters: value<br>Description: <span style="color:rgb(0,0,0);">Brings focus to a given element.</span><br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fd"> <p><code>navigateTo("</code>http://demosite.appvance.com/<code>");</code><br><code>focus(span("Products[1]"));</code><br><code>click(span("Products[1]"));</code><br><code>click(link("Clothing"));</code></p> </blockquote> <h3 id="bkmrk-_focuswindow-%3D-focus">_focusWindow = focusWindow</h3> <p id="bkmrk-parameters%3Adescripti">Parameters:<br>Description: <span style="color:rgb(0,0,0);">Brings the window above all other windows. It is generally needed before using other native events or before taking screen shots Works only on Windows Operating Systems currently. On Mac and Linux, does nothing. For popup windows, use _selectWindow first.</span><br>See also: <strong>selectWindow</strong><br>Example:</p> <blockquote id="bkmrk-_focuswindow%28%29%3B-%2F%2F-b"> <p><code>_focusWindow(); // bring window into focus.</code> <br> </p> </blockquote> <h3 id="bkmrk-_getalllinks-%3D-getal">_getAllLinks = getAllLinks</h3> <p id="bkmrk-description%3A-used-to">Description: used to retrieve all anchor elements/links in an HTML page.<br>Example:</p> <blockquote id="bkmrk-getalllinks%28%29%3B"> <p><code>getAllLinks();</code> </p> </blockquote> <img src="../../../Resources/Images/GeneralGraphics/image-20230211-161112.png" id="bkmrk--2" alt="image-20230211-161112.png"> <h3 id="bkmrk-_getattribute-%3D-geta">_getAttribute = getAttribute</h3> <p id="bkmrk-parameters%3A-element%2C">Parameters: element, attrName<br>Description: used to retrieve the attribute value by specifying the name for a given element<br>Example:</p> <blockquote id="bkmrk-var-href-%3D-getattrib"> <p><code>var href = getAttribute(link("id"),"href");</code> <br><code>log("href:" + href);</code> </p> </blockquote> <blockquote id="bkmrk--3"> <p> <br> </p> </blockquote> <h3 id="bkmrk-_getbrowserurl-%3D-get">_getBrowserURL = getBrowserURL</h3> <p id="bkmrk-description%3A-returns">Description: returns the Browser URL.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-1"> <p><code>navigateTo("</code>http://sahitest.com/<code>demo");</code><br><code>assertEqual("</code>http://sahitest.com/demo/",getBrowserURL())<code>;</code></p> </blockquote> <h3 id="bkmrk-_getchildelementcoun">_getChildElementCount = getChildElementCount</h3> <p id="bkmrk-paramters%3Aelem">Paramters:elem</p> <p id="bkmrk-description%3A-used-to-1">Description: Used to find the count of child elements considering given the element as parent.</p> <p id="bkmrk-example%3A-2">Example:</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-3"> <p><code>navigateTo("</code>https://www.apple.com/<code>");</code><br><code>click(link("Apple[1]"));</code><br><code>click(link("iPad"));</code><br><code>var dyn1 = <span>childElementCount</span>(div('ac-gn-content'));</code><br><code>assertEquals(4,dyn1);</code><br><code>//log(childElementCount('.ac-gn-content'));//class name selector</code><br><code>assertEquals(14,childElementCount(div('main'))); //id selector</code></p> </blockquote> <h3 id="bkmrk-_getclipboardtext-%3D-">_getClipboardText = _getClipboardText</h3> <p id="bkmrk-parameters%3A-variable">Parameters: variable<br>See Also: <strong>grantPermissions</strong></p> <p id="bkmrk-description%3A-used-to-2">Description: Used to retrieve the contents of the clipboard to a variable. Needs to grant the clipboard permission first. Only works with custom profile in IDE. Not works in scenario editor executions as browser opening in the test node are in incognito mode.<br>Version: 4.8.5 +</p> <p id="bkmrk-example%3A-3">Example:</p> <blockquote id="bkmrk-grantpermission%28%22htt"> <p><code>grantPermission("https://mydomain.com", "clipboardReadWrite");</code> <br><code>getClibboardText($theClipboard);</code> </p> </blockquote> <h3 id="bkmrk-_getcomputedstyle-%3D-">_getComputedStyle = getComputedStyle</h3> <p id="bkmrk-parameters%3A-elem%2C-pa">Parameters: elem, param<br>Description:</p> <p id="bkmrk-the-getcomputedstyle">The getComputedStyle() method gets all the actual (computed) CSS property and values of the specified element.</p> <p id="bkmrk-the-computed-style-i">The computed style is the style actually used in displaying the element, after "stylings" from multiple sources have been applied.</p> <p id="bkmrk-style-sources-can-in">Style sources can include: internal style sheets, external style sheets, inherited styles and browser default styles.</p> <p id="bkmrk-example%3A-4">Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fd-1"> <p><code>navigateTo("</code>http://demosite.appvance.com/<code>");</code><br><code>var color=getComputedStyle(header("header"),"background-color");</code><br><code>log(color);</code><br><code>assertEqual("rgba(34, 34, 34, 0.4)",color);</code></p> </blockquote> <h3 id="bkmrk-_gethtml-%3D-gethtml">_getHtml = getHtml</h3> <p id="bkmrk-description%3A-retriev">Description: retrieves the HTML of the current page.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-2"> <p>navigateTo("http://sahitest.com/");<br>click(link("/demo"));<br>click(link("containTest.htm"));<br>var myHTML = getHtml();<br>log(myHTML);<br>var index = myHTML.indexOf("abc")+"";<br>log(index);<br>assertEquals(index,"896");</p> </blockquote> <h3 id="bkmrk-_getlength-%3D-getleng">_getLength = getLength</h3> <p id="bkmrk-parameters%3A-valuedes-1">Parameters: value<br>Description: this is generally used to get the length of rows or columns from a table.<br>Example:</p> <blockquote id="bkmrk-var-%24length-%3D_getlen"> <p><code>var $length =_getLength('.v-table-table tr')</code> <br><code>// .v-table-table is the class name</code> <br><code>// and tr will be rows</code> </p> </blockquote> <h3 id="bkmrk-_getprop-%3D-getprop">_getProp = getProp</h3> <p id="bkmrk-parameters%3A-valuedes-2">Parameters: value<br>Description: to get the element property value (similar to jquery .prop())<br>Example:</p> <blockquote id="bkmrk-var-optionindex-%3D_ge"> <p><code>var optionIndex =_getProp(option('Dashboard'),"selectedIndex")</code> </p> </blockquote> <h3 id="bkmrk-_getscrolltop-%3D-gets">_getScrollTop = getScrollTop</h3> <p id="bkmrk-parameters%3A-targetex">Parameters: target<br>Example: Get the current vertical position of the scroll bar for the first element in the matched elements. See also setScrollTop.</p> <blockquote id="bkmrk-_navigateto%28%22https%3A%2F-1"> <p><code>_navigateTo("</code>https://api.jquery.com/scrollTop/<code>");</code><br><code>_selectMainFrame();</code><br><code>_setScrollTop(_byXPath("//html"),300); //Firefox Only</code><br><code>_assertEqual(300,_getScrollTop(_byXPath("//html"))); //Firefox Only</code></p> </blockquote> <h3 id="bkmrk-_gettext-%3D-gettext">_getText = getText</h3> <p id="bkmrk-parameters%3A-elementd">Parameters: element<br>Description: <span style="color:rgb(0,0,0);">The returned string is normalized for different browsers. Multiple continuous spaces are replaced with a single space. Multiple continuous newlines are replaced with a single newline. Newlines are always returned as \n even on Mac and Linux so that scripts can work across browsers and OSes. </span><br><span style="color:rgb(0,0,0);">This API uses the textContent or innerText attributes of elements. </span><br>Example:</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-4"> <p><code>navigateTo("</code>https://www.apple.com/<code>");</code><br><code>click(_link("Music"));</code><br><code>click(_link("Mac"));</code><br><code>var val1=getText(link("iPad"));</code><br><code>log(val1);</code><br><code>click(link("/ipad/"));</code></p> </blockquote> <h3 id="bkmrk-_gettextselenium-%3D-g">_getTextSelenium = getTextSelenium</h3> <p id="bkmrk-parameters%3A-elementd-1">Parameters: element<br>Description: This is similar to getText, but this will return the trimmed text of the HTML.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-5"> <p><code>navigateTo("</code>https://www.apple.com/<code>");</code><br><code>click(_link("Music"));</code><br><code>click(_link("Mac"));</code><br><code>var val1=getTextSelenium(link("iPad"));</code><br><code>log(val1);</code><br><code>click(link("/ipad/"));</code></p> </blockquote> <h3 id="bkmrk-_title-%3D-_gettitle-%3D">_title = _getTitle = getTitle</h3> <p id="bkmrk-description%3A-returns-1">Description: returns the window's title.<br>Example:</p> <blockquote id="bkmrk-log%28%22title%3A-%22%2B-getti"> <p><code>log("title: "+ getTitle());</code> </p> </blockquote> <h3 id="bkmrk-_getvalue-%3D-getvalue">_getValue = getValue</h3> <p id="bkmrk-parameters%3A-elemdesc">Parameters: elem<br>Description: This API only works on elements that take user text input. To get text out of a div or a span like elements, use <strong>_getText</strong> bettr<br>Example:</p> <blockquote id="bkmrk-assertequal%28%22appvanc"> <p><code>assertEqual("Appvance", getValue(_textbox("company")));</code> </p> </blockquote> <h3 id="bkmrk-_getsmarttags-%3D-gets">_getSmartTags = getSmartTags</h3> <p id="bkmrk-parameters%3A-type%2C-%5Bc">Parameters: type, [config]<br>Description: Used to retrieve the SmartTags data once the SmartTags library is loaded.<br>See also: addSmartTagsLibrary<br>Example:</p> <blockquote id="bkmrk-addsmarttagslibrary%28-1"> <p><code>addSmartTagsLibrary("{ds}/test.stags");</code> <br><code>navigateTo("</code>https://www.appvance.com/<code>");</code><br><code>var radioWidgets = getSmarTags("name"); //can also give as getSmartTags() without any paramters to fetch everything</code></p> </blockquote> <h3 id="bkmrk-_getsmarttagslibrary">_getSmartTagsLibrary = getSmartTagsLibrary</h3> <p id="bkmrk-parameters%3A-type%2C-%5Bc-1">Parameters: type, [config]<br>Description: Returns the SmartTags library as a json string<br>See also: <strong>addSmartTagsLibrary</strong><br>Example:</p> <blockquote id="bkmrk-addsmarttagslibrary%28-2"> <p><code>addSmartTagsLibrary("{ds}/test.stags");</code> <br><code>navigateTo("</code>https://www.appvance.com/<code>");</code><br><code>var json = getSmarTagsLibrary(); </code></p> </blockquote> <h3 id="bkmrk-_grantpermission-%3D-g">_grantPermission = grantPermission</h3> <p id="bkmrk-parameters%3A-domain%2C-">Parameters: domain, permission<br>The permission parameter allowed values can be seen <a href="https://chromedevtools.github.io/devtools-protocol/tot/Browser/#type-PermissionType">here</a>.<br>Description: Use this command to grant browser permissions to mic, or clipboard.<br>See also: <strong>getClipboardText</strong><br>Usage: This will<strong> only work in IDE </strong>using a custom profile set for <strong>NON-Incognito</strong> mode.</p> <img src="../../../Resources/Images/GeneralGraphics/Screen%20Shot%202023-02-01%20at%2014.11.15.png" id="bkmrk--4" alt="Screen%20Shot%202023-02-01%20at%2014.11.15.png"> <p id="bkmrk-version%3A-4.8.5-%2B-exa">Version: 4.8.5 + <br>Example:</p> <blockquote id="bkmrk-grantpermission%28%22htt-1"> <p><code>grantPermission("https://mydomain.com", "clipboardReadWrite");</code> <br><code>grantPermission("https://mydomain.com", "audioCapture");</code> <br> </p> </blockquote> <h3 id="bkmrk-_highlight-%3D-highlig">_highlight = highlight</h3> <p id="bkmrk-parameters%3A-target%2C--6">Parameters: target, value<br>Description: Adds a color border around the provided target element. Use for debugging purposes.<br>Example: The following code highlights a smarttag element with a red border. </p> <blockquote id="bkmrk-addwidgetlibrary%28%22%7Bd"> <p><code>addWidgetLibrary("{ds}/ServiceNowWidgets.json");</code> <br><code>navigateTo("</code>https://demosite.appvance.com<code>");</code><br><code>highlight(ForgotPasswordLink(),"red");</code></p> </blockquote> <h3 id="bkmrk-_include-%3D-include">_include = include</h3> <p id="bkmrk-parameters%3A-scriptde">Parameters: script<br>Description: <br><span style="color:rgb(0,0,0);">Includes the script at script Path in the current script. </span><br>To reuse a function from one script in another, we include the relevant script using the Include Action API from DS3.<br>This will be helpful in shortening your designer scripts and mainly with the re-usability of certain scripts.<br>Call other scripts as functions. This will let users to Include other DS3 scripts at any given step<br>Test Designer supports relative paths ("{ds} means the folder where the current script is saved"), the scripts can be run from both Designer and as well as from the Scenario Builder.</p> <p id="bkmrk-example%3A-5">Example:</p> <blockquote id="bkmrk-include%28%22%7Bds%7D%2Floginw"> <p><code>include("{ds}/loginWithDPL.js");</code> <br><code>setValue(textbox("q"),$MOBILENO);</code> <br><code>setValue(textbox("q[1]"),$PASSWORD);</code> <br><code>setValue(textbox("q[2]"),$DATE);</code> <br><code>click(button("Add"));</code> <br><code>include("{ds}/logout.js");</code> </p> </blockquote> <h3 id="bkmrk-_ischecked-%3D-ischeck">_isChecked = isChecked</h3> <p id="bkmrk-parameters%3A-targetde-1">Parameters: target<br>Description: <span style="color:rgb(0,0,0);">Returns true if element is checked, else false</span><br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fl"> <p><code>navigateTo("</code>http://localhost:8080/UI/index.html<code>");</code><br><code>setValue(textbox("username"),"appvance");</code><br><code>setValue(password("password"),"appvance");</code><br><code>click(button("login"));</code><br><code>click(link("ResultsTab"));</code><br><code>if (_isChecked(checkbox("resultsEnabled"))){</code><br><code> click(link("resultsAccept"));</code><br><code> assertExists(paragraph("Saved successfully"));</code><br><code>}</code><br><code> else {</code><br><code> click(checkbox(1));</code><br><code>}</code></p> </blockquote> <h3 id="bkmrk-_isvisible-%3D-isvisib">_isVisible = isVisible</h3> <p id="bkmrk-parameters%3A-valuedes-3">Parameters: value<br>Description: <br><span style="color:rgb(0,0,0);">isVisible</span> returns true if the element is visible, else false. This can be used in combination with conditional statements (example shown below) or with Assertions.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-3"> <p><code>navigateTo("</code>http://sahitest.com/demo/<code>");</code><br><code>click(link("a x"));</code><br><code>var var1= isVisible(link("linkById"));</code><br><code>log(var1);</code><br><code>if (var1==true){</code><br><code> click(link("linkById"));</code><br><code>}</code><br><code>click(link("linkTest.htm"));</code><br><code>click(bold("linkByHtml"));</code></p> </blockquote> <h3 id="bkmrk-_lastalert-%3D-lastale">_lastAlert = lastAlert</h3> <p id="bkmrk-description%3Acontents">Description:<span style="color:rgb(0,0,0);">contents of the last pop up</span><br>See also: _checkLastAlert<br>Example:</p> <blockquote id="bkmrk-var-%24ch2%3Deval%28_lasta"> <p><code>var $ch2=eval(_lastAlert()) </code> </p> </blockquote> <h3 id="bkmrk-_locker-%3D-locker">_locker = locker</h3> <p id="bkmrk-parameters%3A-key%2C-val">Parameters: key, value<br>Description: Stores the data into The Locker with a given key name.<br>See also: _retrieve<br>Example:<br>A simple example in JS:</p> <blockquote id="bkmrk-var-%24msg%3D_gettext%28_d"> <p><code>var $msg=_getText(_div("custdialog"));</code> <br><code>locker("message",$msg);</code> </p> </blockquote> <p id="bkmrk-in-ds-%28ide%29%3A"><span style="color:rgb(0,0,0);">in DS (IDE):</span> </p> <blockquote id="bkmrk-store-in-locker-%7C-%22m"> <p><code>Store in Locker | "message" | _getText(_div("custdialog"))</code> </p> </blockquote> <img src="../../../Resources/Images/GeneralGraphics/image2018-5-24_18-18-24.png" id="bkmrk--5" alt="image2018-5-24_18-18-24.png"> <h3 id="bkmrk-_log-%3D-log-%3D-_printl">_log = log = _println;</h3> <p id="bkmrk-description%3A-logs-me">Description: Logs messages<br>Example:</p> <blockquote id="bkmrk-_log%28%22current-user-i"> <p><code>_log("Current user is " + $user); // Will log as plain text</code> </p> </blockquote> <h3 id="bkmrk-_mousedown-%3D-mousedo">_mouseDown = mouseDown</h3> <p id="bkmrk-parameters%3A-target%2C--7">Parameters: target, options<br>Description:<br>Example: Simulates a mouse Down event on the element.</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-6"> <p><code>navigateTo("</code>https://www.demosite.appvance.com/<code>");</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"));</code><br><code>mouseDown(link("ac-gn-link ac-gn-link-tv"));</code></p> </blockquote> <h3 id="bkmrk-_mousedownxy-%3D-mouse">_mouseDownXY = mouseDownXY</h3> <p id="bkmrk-parameters%3A-target%2C--8">Parameters: target, xy, options<br>Description:<br>Example: <span style="color:rgb(0,0,0);">Simulates a mouse down event at the point (x,y).</span><br></p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-7"> <p><code>navigateTo("</code>https://www.demosite.appvance.com/<code>");</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"));</code><br><code>mouseDownXY(link("ac-gn-link ac-gn-link-tv"),"30,10");</code></p> </blockquote> <h3 id="bkmrk-_mouseover-%3D-mouseov">_mouseOver = mouseOver</h3> <p id="bkmrk-parameters%3A-target%2C--9">Parameters: target, options<br>Description: <span style="color:rgb(0,0,0);">mouseOver simulates a mouse hovering on the given element.</span></p> <p id="bkmrk-example%3A-6">Example:</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-8"> <p><code>navigateTo("</code>https://www.ted.com/about/programs-initiatives/tedx-program<code>");</code><br><code>mouseOver(link("Watch"));</code><br><code>click(div("TED Talks"));</code><br><code>setSelected(select("topics"),"Technology");</code><br><code>setSelected(select("languages"),"en");</code><br><code>setSelected(select("duration"),"0-6");</code></p> </blockquote> <h3 id="bkmrk-_mouseoverxy-%3D-mouse">_mouseOverXY = mouseOverXY</h3> <p id="bkmrk-parameters%3A-target%2C--10">Parameters: target, xy, options<br>Description:<br>Example: <span style="color:rgb(0,0,0);">Simulates a mouse hover event at the point (x,y).</span><br></p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-9"> <p><code>navigateTo("</code>https://www.demostie.appvance.com/<code>");</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"));</code><br><code>mouseOverXY(link("ac-gn-link ac-gn-link-tv"),"30,10");</code></p> </blockquote> <h3 id="bkmrk-_mouseoutall-%3D-mouse">_mouseOutAll = mouseOutAll</h3> <p id="bkmrk-parameters%3A-nothingd">Parameters: nothing<br>Description: Triggers the mouse out handler for the entire body of HTML<br>Example:</p> <blockquote id="bkmrk-mouseoutall%28%29%3B"> <p><code>mouseOutAll();</code> </p> </blockquote> <h3 id="bkmrk-_mouseup-%3D-mouseup">_mouseUp = mouseUp</h3> <p id="bkmrk-parameters%3A-target%2C--11">Parameters: target, options<br>Description: the mouse up event is sent to an element when the mouse pointer is over the element, and the mouse button is released. Any HTML element can receive this event.<br>Example: <span style="color:rgb(0,0,0);">Simulates a mouse release event.</span><br></p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-10"> <p><code>navigateTo("</code>https://www.demostie.appvance.com/<code>");</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"));</code><br><code>mouseUp(link("ac-gn-link ac-gn-link-tv"));</code></p> </blockquote> <h3 id="bkmrk-_mouseupxy-%3D-mouseup">_mouseUpXY = mouseUpXY</h3> <p id="bkmrk-parameters%3A-target%2C--12">Parameters: target, xy, options<br>Description:<br>Example: <span style="color:rgb(0,0,0);">Simulates a mouse release event at the point (x,y).</span><br></p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-11"> <p><code>navigateTo("</code>https://www.demostie.appvance.com/<code>");</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"));</code><br><code>mouseUpXY(link("ac-gn-link ac-gn-link-tv"),"30,10");</code></p> </blockquote> <h3 id="bkmrk-_readcsv-%3D-readcsv">_readCSV = readCSV</h3> <p id="bkmrk-parameters%3A-filename">Parameters: filename<br>Description: reads a CSV file and stores it into a two-dimensional array variable.<br>Example:</p> <div style="border-width:1px;" id="bkmrk-var-%24csvtxt-%3D-%22usern"> <div><pre>var $csvtxt = "username,password"+"\n"+"oscar,passw"+"\n"+"oscar2,passw2"; // $csvtxt could be variable with contents captured by network workbench extractor writeText("{ds}/mycsv.csv", $csvtxt ); var data = readCSV("{ds}/mycsv.csv"); log(data.length); // includes first header row for (var i = 1; i &lt; data.length; i++) { var $username = data[i][0]; var $password = data[i][1]; log("$username: "+$username+" $password: "+$password); }</pre> </div> </div> <p id="bkmrk--6"> <br> </p> <h3 id="bkmrk-_resetuseragent-%3D-re">_resetUserAgent = resetUserAgent</h3> <p id="bkmrk-parameters%3A-domain">Parameters: domain</p> <p id="bkmrk-description%3A-restore">Description: Restore the default browser user agent for the indicated domain requests</p> <p id="bkmrk-important%3A-this-comm">IMPORTANT: this command has a global effect over the DSServer, so all test designer tests running using the referenced domain, will have its request to that domain reset to use the real browser the test is being run on. This command should most likely never be called unless you know for certain no one is using the affected domain at the same time. Resetting the DS3Server domain will effectively reset all domains set by <strong>setUserAgent</strong>.</p> <p id="bkmrk-example%3A-7">Example:</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-12"> <p><code>navigateTo("</code>https://cecristest.crm9.dynamics.com<code>");</code><br><code>setUserAgent("</code>sts.dss.ca.gov<code>", "chrome");</code><br><code>setUserAgent("</code>cecristest.crm9.dynamics.com<code>", "firefox");</code><br><code>setValue(emailbox("i0116"),"myusername@</code>appvance.com<code>");</code><br><code>resetUserAgent("</code>sts.dss.ca.gov<code>");</code><br><code>resetUserAgent("</code>cecristest.crm9.dynamics.com<code>");</code></p> </blockquote> <h3 id="bkmrk-_retrieve">_retrieve</h3> <p id="bkmrk-parameters%3A-keydescr">Parameters: key<br>Description: Retrieves the value from the locker given a key name<br>Example:</p> <p id="bkmrk-javascript-%28.js%29">Javascript (.js)</p> <blockquote id="bkmrk-retrieve%28myvariable%2C"> <p><code>retrieve(<span>myVariable</span>, "message");</code> </p> </blockquote> <p id="bkmrk-ide-%28.ds%29"> <br>IDE (.ds)</p> <img src="../../../Resources/Images/GeneralGraphics/image2018-5-24_18-19-20.png" id="bkmrk--7" alt="image2018-5-24_18-19-20.png"> <h3 id="bkmrk-_rightclick-%3D-rightc">_rightClick = rightClick</h3> <p id="bkmrk-parameters%3A-targetde-2">Parameters: target<br>Description: simulates the double clicks on the given target element. <br>Example:</p> <blockquote id="bkmrk-_navigateto%28%22http%3A%2F%2F-2"> <p><code>_navigateTo("</code>http://swisnl.github.io/jQuery-contextMenu/demo.html<code>");</code><br><code>_rightClick(_span("right click me"));</code></p> </blockquote> <h3 id="bkmrk-_rightclickxy-%3D-righ">_rightClickXY = rightClickXY</h3> <p id="bkmrk-parameters%3A-target%2C--13">Parameters: target, x, y, options<br>Description: <span style="color:rgb(0,0,0);">Simulates a right click event at the point (x,y).</span><br>Example: </p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-13"> <p><code>navigateTo("</code>https://www.demosite.appvance.com/<code>");</code><br><code>click(link("ac-gn-link ac-gn-link-iphone"));</code><br><code>rightClickXY(link("ac-gn-link ac-gn-link-tv"),"30,10");</code></p> </blockquote> <h3 id="bkmrk-_rtehtml-%3D-rtehtml">_rteHTML = rteHTML</h3> <p id="bkmrk-parameters%3A-targetde-3">Parameters: target<br>Description: Gets the innerHTML contents of <span>the Rich Text Editor object</span>.</p> <p id="bkmrk-example%3A-8">Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fa"> <p><code>navigateTo("</code>http://<code>aplicationURL");</code><br><code>click(link("ClickToLogin"));</code><br><code>setValue(textbox("userId"),"Tracy");</code><br><code>setValue(password("password"),"pass");</code><br><code>click(button("Login"));</code><br><code>rteWrite(iframe("k-content"),"Text data");</code><br><code>var dyn2=rteHTML(iframe("k-content"));</code><br><code>log(dyn2);</code><br><code>click(link("Logout"));</code></p> </blockquote> <h3 id="bkmrk-_rtetext-%3D-rtetext">_rteText = rteText</h3> <p id="bkmrk-parameters%3A-targetde-4">Parameters: target<br>Description: Gets the text contents of the <span>Rich Text Editor object</span>.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fa-1"> <p><code>navigateTo("</code>http://A<code>pplicationURL");</code><br><code>click(link("ClickToLogin"));</code><br><code>setValue(textbox("userId"),"Tracy");</code><br><code>setValue(password("password"),"pass");</code><br><code>click(button("Login"));</code><br><code>var dyn1=rteText(iframe("k-content"));</code><br><code>log(dyn1);</code><br><code>click(link("Logout"));</code></p> </blockquote> <h3 id="bkmrk-_rtewrite-%3D-rtewrite">_rteWrite = rteWrite</h3> <p id="bkmrk-parameters%3A-target%2C--14">Parameters: target, value<br>Description: </p> <p id="bkmrk-rich-text-editors-%28r">Rich Text Editors (RTEs) are iframes/divs whose design mode or content Editable property is set to true. Such components allow input of text and formatting them (making text bold, inserting images, etc.).<br>Rich Text Editors do not respond to regular events and need to be handled specifically. For now, the Recording of such events is not possible in DS3, Only replay can be done.</p> <p id="bkmrk-example%3A-9">Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fa-2"> <p><code>navigateTo("</code>http://ApplicationURL<code>");</code><br><code>click(link("ClickToLogin"));</code><br><code>setValue(textbox("userId"),"Tracy");</code><br><code>setValue(password("password"),"pass");</code><br><code>click(button("Login"));</code><br><code>var dyn1=rteText(iframe("k-content"));</code><br><code>log(dyn1);</code><br><code>rteWrite(iframe("k-content"),"Text data");</code><br><code>click(link("Logout"));</code></p> </blockquote> <h3 id="bkmrk-_setactiondesc-%7C-set">_setActionDesc | setActionDesc</h3> <p id="bkmrk-parameter%3A-descripti">Parameter: description<br>Description: Sets a string to be displayed when action is reported<br>Example:</p> <blockquote id="bkmrk-_navigateto%28%22http%3A%2F%2F-3"> <p><code>_navigateTo("</code>http://sahitest.com/<code>");</code><br><code>_click(_link("demo"));</code><br><code>_click(_link("Link Test"));</code><br><code>_setActionDesc("Type T1");</code><br><code>_setValue(_textbox("t1"),"asdf");</code></p> </blockquote> <h3 id="bkmrk-_sendkeys-%3D-sendkeys">_sendKeys = sendKeys</h3> <p id="bkmrk-parameters%3A-target%2C--15">Parameters: target, value<br>Description: <span style="color:rgb(0,0,0);">Send Keys is very similar to Set Value and the syntax and usage follows exactly the same as Set Value, Send Keys is required to use for some applications where using Set Value, it causes duplicate entries that get inserted since Set Value inputs the entire sting as a whole but Send Keys inserts the value letter by letter like type command provided by Selenium IDE.</span><br>Example: </p> <blockquote id="bkmrk-sendkeys%28textbox%28%22us"> <p><code>sendKeys(textbox("username"),"username");</code> <br><code>sendKeys(password("password"),"password");</code> </p> </blockquote> <h3 id="bkmrk-_setattribute-%3D-_set">_setAttribute = _setAttribute</h3> <p id="bkmrk-parameters%3A-target%2C--16">Parameters: target, attrName, attrValue<br>Description: Used to set the attribute value to a given element<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-4"> <p><code>navigateTo("</code>http://sahitest.com/<code>");</code><br><code>click(link("demo"));</code><br><code>click(link("Link Test"));</code><br><code>_setAttribute(textbox("t1"),"value","20/08/2018");</code></p> </blockquote> <h3 id="bkmrk-_setchecked-%3D-setche">_setChecked = setChecked</h3> <p id="bkmrk-parameters%3A-target%2C--17">Parameters: target, boolean<br>Description: This will check/uncheck the element based on the boolean value given as input.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-5"> <p><code>navigateTo("</code>http://sahitest.com/<code>");</code><br><code>click(link("demo"));</code><br><code>click(link("Form Test"));</code><br><code>setChecked(checkbox("c1"),false);</code><br><code>setChecked(checkbox("c1"),true);</code></p> </blockquote> <h3 id="bkmrk-_setenabled-%3D-_seten">_setEnabled = _setEnabled</h3> <p id="bkmrk-parameters%3A-target%2C--18">Parameters: target, boolean<br>Description: Used to make the given target in enabled/disabled state according to boolean value provided<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-6"> <p><code>navigateTo("</code>http://sahitest.com/<code>");</code><br><code>click(link("demo"));</code><br><code>click(link("Form Test"));</code><br><code>_setEnabled(textbox("textdisabled"),true);</code><br><code>_setEnabled(textbox("textdisabled"),false);</code></p> </blockquote> <h3 id="bkmrk-_setfile-%7C-setfile">_setFile | setFile</h3> <p id="bkmrk-parameters%3A-element%2C-1">Parameters: element, filepath<br>Description: File upload. See also setFile2, setFile3, setFile4 and setFile5.<br>Example:</p> <blockquote id="bkmrk-_navigateto%28%22http%3A%2F%2F-4"> <p><code>_navigateTo("</code>http://sahitest.com/<code>");</code><br><code>_click(_link("demo"));</code><br><code>_click(_link("File Upload Test"));</code><br><code>_setFile(_byXPath('//*[@id="file"]'),"{ds}/test.txt");</code><br><code>_click(_submit("submit"));</code></p> </blockquote> <h3 id="bkmrk-_setfile2-%7C-setfile2">_setFile2 | setFile2</h3> <p id="bkmrk-parameters%3A-element%2C-2">Parameters: element, filepath<br>Description: File upload.This can be used in situations where there are some UI validations to browse box/file input box.This will simply mimic the normal user handling in the sense . browsing the file from location and clicking on Upload.Please remember this can be used only in recent chrome and FF.Not supported with IE/headless FF.Supports all text file formats(txt,doc,csv)<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-7"> <p><code>navigateTo("</code>http://sahitest.com/<code>");</code><br><code>click(link("/demo"));</code><br><code>click(link("/demo/php/fileUpload.htm"));</code><br><code>log(getHtml());</code><br><code>setFile2(byXPath('//*[@id="file"]'),"3521.txt");</code><br><code>click(submit("submit"));</code></p> </blockquote> <h3 id="bkmrk-_setfile3-%7C-setfile3">_setFile3 | setFile3</h3> <p id="bkmrk-parameters%3A-element%2C-3">Parameters: element, filepath<br>Description: File upload.Same as that of setFile2 .The difference is most of the modern apps do upload automatically once the file is selected without needing to click the upload button or a change mouse event. So this will come handy in these cases.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-8"> <p><code>navigateTo("</code>http://sahitest.com/<code>");</code><br><code>click(link("/demo"));</code><br><code>click(link("/demo/php/fileUpload.htm"));</code><br><code>log(getHtml());</code><br><code>setFile3(byXPath('//*[@id="file"]'),"3521.doc");</code><br><code>click(submit("submit"));</code></p> </blockquote> <h3 id="bkmrk-_setfile4-%7C-setfile4">_setFile4 | setFile4</h3> <p id="bkmrk-parameters%3A-element%2C-4">Parameters: element, filepath<br>Description: File upload. All image files can be uploaded using this as image file needs some processing such as hexa to binary of its contents in order to retain the size of images.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-9"> <p><code>navigateTo("</code>http://sahitest.com/<code>");</code><br><code>click(link("/demo"));</code><br><code>click(link("/demo/php/fileUpload.htm"));</code><br><code>log(getHtml());</code><br><code>setFile4(byXPath('//*[@id="file"]'),"3521.png");</code><br><code>click(submit("submit"));</code></p> </blockquote> <h3 id="bkmrk-_setfile5-%7C-setfile5">_setFile5 | setFile5</h3> <p id="bkmrk-parameters%3A-element%2C-5">Parameters: element, filepath<br>Description: File upload. - Video/Audio/Zip files can be uploaded using this.<br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-10"> <p><code>navigateTo("</code>http://sahitest.com/<code>");</code><br><code>click(link("/demo"));</code><br><code>click(link("/demo/php/fileUpload.htm"));</code><br><code>log(getHtml());</code><br><code>setFile5(byXPath('//*[@id="file"]'),"3521.mp4");</code><br><code>click(submit("submit"));</code></p> </blockquote> <h3 id="bkmrk-_setfindonlyenabled-">_setFindOnlyEnabled = setFindOnlyEnabled</h3> <p id="bkmrk-parameters%3A-booleand">Parameters: boolean<br>Description: Find the element only if it is enabled on the page.</p> <p id="bkmrk-example%3A-10">Example:</p> <blockquote id="bkmrk-_navigateto%28%22https%3A%2F-2"> <p><code>_navigateTo("</code>https://www.apple.com<code>");</code><br><code>var elems = links();</code><br><code>assertEqual(91,elems.size());</code><br><code>_setFindOnlyEnabled(true);</code><br><code>var elems = links();</code><br><code>assertEqual(91,elems.size());</code><br><code>_setFindOnlyEnabled(false);</code><br><code>var elems = links();</code><br><code>assertEqual(91,elems.size());</code></p> </blockquote> <h3 id="bkmrk-_setfindonlyvisible-">_setFindOnlyVisible = setFindOnlyVisible</h3> <p id="bkmrk-parameters%3A-booleand-1">Parameters: boolean<br>Description: Finds only if the element is visible on the page.<br>Example:</p> <blockquote id="bkmrk-_navigateto%28%22https%3A%2F-3"> <p><code>_navigateTo("</code>https://www.apple.com<code>");</code><br><code>var elems = links();</code><br><code>assertEqual(91,elems.size());</code><br><code>_setFindOnlyVisible(true);</code><br><code>var elems = links();</code><br><code>assertEqual(91,elems.size());</code><br><code>_setFindOnlyVisible(false);</code><br><code>var elems = links();</code><br><code>assertEqual(91,elems.size());</code></p> </blockquote> <h3 id="bkmrk-_sethtml-%3D-sethtml">_setHTML = setHTML</h3> <p id="bkmrk-parameters%3A-target%2C--19">Parameters: target, value<br>Description: sets the HTML content (innerText/textContent) to iframe element. This automatically gets recorded when setting the data inside an iframe.<br>Example:</p> <blockquote id="bkmrk-sethtml%28frame%28%22id%22%29%2C"> <p><code>setHTML(frame("id"),"setting iframe content")</code> </p> </blockquote> <h3 id="bkmrk-_setscrolltop-%3D-sets"><span>_setScrollTop = setScrollTop</span> </h3> <p id="bkmrk-parameters%3A-target%2C--20">Parameters: target, scrollTop<br>Description: <br>Example:</p> <blockquote id="bkmrk-_navigateto%28%22https%3A%2F-4"> <p><code>_navigateTo("</code>https://api.jquery.com/scrollTop/<code>");</code><br><code>_selectMainFrame();</code><br><code>_setScrollTop(_byXPath("//html"),300);//FirefoxOnly</code><br><code>_assertEqual(300,_getScrollTop(_byXPath("//html")));//FirefoxOnly</code><br><code>_setEnabled(_button(0),false);</code><br><code>_assertEqual("</code>http://jquery.com/download/",_getAttribute(_link("Download"),"href<code>"));</code><br><code>_setAttribute(_link("Download"),"href","</code>http://jquery.com/local/<code>");</code><br><code>_assertEqual("</code>http://jquery.com/local/",_getAttribute(_link("Download"),"href<code>"));</code></p> </blockquote> <h3 id="bkmrk-_setsearchretries-%3D-">_setSearchRetries = setSearchRetries</h3> <p id="bkmrk-parameters%3A-valuedes-4">Parameters: value<br>Description: Controls the maximum number of retries spent trying to find an element. The default search process will retry 12 times (~ 90 seconds). This value can be used to reduce the time spent finding an element by reducing the number of retries.<br>Example:</p> <blockquote id="bkmrk-setsearchretries%286%29%3B"> <p><code>setSearchRetries(6);</code> </p> </blockquote> <h3 id="bkmrk-_setselected-%3D-setse"><span>_setSelected = setSelected</span> </h3> <p id="bkmrk-parameters%3A-target%2C--21">Parameters: target, boolean<br>Description: <span style="color:rgb(0,0,0);">Selects one or more elements in a select dropdown.</span><br>Example:</p> <blockquote id="bkmrk-navigateto%28%22http%3A%2F%2Fs-11"> <p><code>navigateTo("</code>http://sahitest.com/demo/<code>");</code><br><code>click(link("selectTest.htm"));</code><br><code>setSelected(select("s1Id"),"o1");</code><br><code>setSelected(select("s2Id"),"o2");</code></p> </blockquote> <h3 id="bkmrk-_setuseragent-%3D-setu">_setUserAgent = setUserAgent</h3> <p id="bkmrk-parameters%3A-domain%2C--1">Parameters: domain, browser</p> <p id="bkmrk-description%3A-overwri">Description: Overwrites the user agent of the current browser for the requests on the indicated domain (domain parameter), for the user agent established as a parameter (chrome, firefox)<br>IMPORTANT: this command has a global effect over the DSServer, so all DS3 test running using the referenced domain, will have its request to that domain set to use the provided browser as its user-agent (Meaning if the target browser is IE and we set the userAgent to be chrome browser, the server of the request (say "appvance.ca.gov", etc) will respond as if it were using "chrome", but the browser will remain IE)</p> <p id="bkmrk-this-call-can-be-don">This call can be done several times without issue by concurrent users as long as setting the same browser per domain, otherwise, they will be changing browsers for all executing tests. So the best practice is to use the same browser per domain along with all the scripts. But values set by this command will not persist a restart of the DS3Server service.</p> <p id="bkmrk-example%3A-11">Example:</p> <blockquote id="bkmrk-navigateto%28%22https%3A%2F%2F-14"> <p><code>navigateTo("</code>https://test.crm9.dynamics.com<code>");</code><br><code>setUserAgent("</code>app.dss.ca.gov<code>", "chrome");</code><br><code>setUserAgent("</code>test.crm9.dynamics.com<code>", "firefox");</code><br><code>setValue(emailbox("i0116"),"myusername@appvance.com");</code></p> </blockquote> <h3 id="bkmrk-_setvalue-%3D-setvalue">_setValue = setValue</h3> <p id="bkmrk-parameters%3A-target%2C--22">Parameters: target, value<br>Description: <span style="color:rgb(0,0,0);">Simulates text entry into html form elements (text-box like elements and text-areas) The sequence of events performed are Focus Enter Text Remove focus. Can use this sequence of characters:</span></p> <div style="border-width:1px;" id="bkmrk-%7B%7Benter%7D%7D"> <div><pre>{{ENTER}} </pre> </div> </div> <p id="bkmrk-to-insert-the-result">to insert the result of hitting the Enter key.</p> <p id="bkmrk-example%3A-12"> <br>Example:</p> <blockquote id="bkmrk-setvalue%28textbox%28%22us"> <p><code>setValue(textbox("username"),"username");</code> <br><code>setValue(password("password"),"password");</code> </p> </blockquote> <h3 id="bkmrk-_popup-%3D-popup"><span>_popup </span>= popup</h3> <p id="bkmrk-parameters%3A-windowna">Parameters: windowName<br>Description:<br>Example:</p> <h3 id="bkmrk-_writetext-%3D-writete">_writeText = writeText</h3> <p id="bkmrk-parameters%3A-writes-a">Parameters: writes a text file to disk.<br>Description:<br>Example:</p> <div style="border-width:1px;" id="bkmrk-var-%24csvtxt-%3D-%22usern-1"> <div><pre>var $csvtxt = "username,password"+"\n"+"oscar,passw"+"\n"+"oscar2,passw2"; // $csvtxt could be variable with contents captured by network workbench extractor writeText("{ds}/mycsv.csv", $csvtxt ); var data = readCSV("{ds}/mycsv.csv"); log(data.length); // includes first header row for (var i = 1; i &lt; data.length; i++) { var $username = data[i][0]; var $password = data[i][1]; log("$username: "+$username+" $password: "+$password); }</pre> </div> </div> <h3 id="bkmrk-_wait-%3D-wait-%28fixed-"> <br>_wait = wait (Fixed duration)</h3> <p id="bkmrk-parameters%3A-millisec">Parameters: milliseconds<br>Description: pauses the execution for the specified number of milliseconds<br>Example:</p> <div style="border-width:1px;" id="bkmrk-wait%2830000%29%3B-%2F%2F-paus"> <div><pre>wait(30000); // pauses for 30 seconds</pre> </div> </div> <h3 id="bkmrk-_wait-%3D-wait-%28condit">_wait = wait (Conditional wait)</h3> <p id="bkmrk-parameters%3A-value%2C-c"><span><span>Parameters</span></span>: <span>value</span>, condition<br>Description: <span style="color:rgb(0,0,0);">Forces script to wait for a given time in millisecond or given </span><strong><span style="color:rgb(0,0,0);">condition</span></strong><span style="color:rgb(0,0,0);"> to be </span><strong><span style="color:rgb(0,0,0);">true</span></strong><span style="color:rgb(0,0,0);">, whichever comes first.</span><br>Conditional testing uses constant pooling, which means TestDesigner tests the function during the wait time, If the function output becomes true, then it stops the wait.</p> <p style="margin-left:30px;" id="bkmrk-there-are-two-ways-t">There are two ways to use <strong>conditional waiting</strong>:</p> <ol start="1" id="bkmrk-to-use-a-function-as"> <li value="1"> <p> To use a <strong>function</strong> as the condition so that will be tested over and over </p> </li> </ol> <div style="border-width:1px;" id="bkmrk-wait%2860000%2C-%28functio"> <div><pre>wait(60000, (function(){ checkSomething () })); wait(Number.MAX_SAFE_INTEGER, ()=&gt; checkSomething () );</pre> </div> </div> <p style="margin-left:30px;" id="bkmrk-2.-define-a-string-a"> <br>2. Define a <strong>String</strong> as the condition that will be evaluated to see if it returns true<br> Notice: value should be <strong>inside quotes</strong> so the string gets evaluated several times during the wait period of time.</p> <div style="border-width:1px;" id="bkmrk-wait%2890000%2C-%22isvisib"> <div><pre>wait(90000, "isVisible(textbox('username'))" );</pre> </div> </div> <h3 style="margin-left:30px;" id="bkmrk-conditional-wait-com"> <br> <br>Conditional Wait Common Issues <br></h3> <ol start="1" id="bkmrk-the-condition-is-not"> <li value="1"> <p>The condition is not a function, but a <strong>value</strong></p> </li> </ol> <div style="border-width:1px;" id="bkmrk-wait%28number.max_safe"> <div><pre>wait(Number.MAX_SAFE_INTEGER, isVisible(Element()) ); </pre> </div> </div> <p style="margin-left:30px;" id="bkmrk-if-the-element-is-in">IF the element is invisible, then the script will not finish, it will get stuck forever because the second parameter is already evaluated, this is exactly the same as </p> <div style="border-width:1px;" id="bkmrk-let-isvisibleresut-%3D"> <div><pre>let isVisibleResut = isVisible(Element()) ; wait(Number.MAX_SAFE_INTEGER,isVisibleResut); </pre> </div> </div> <p style="margin-left:30px;" id="bkmrk-if-isvisibleresut-is">if isVisibleResut is false, it will never change its value. </p> <p style="margin-left:30px;" id="bkmrk--8"></p> <p style="margin-left:30px;" id="bkmrk-2%29-the-condition-fun">2) The condition function fails/breaks </p> <p style="margin-left:30px;" id="bkmrk-wait%28number.max_safe-1">wait(Number.MAX_SAFE_INTEGER, ()=&gt;{throw Exception()} ); </p> <p style="margin-left:30px;" id="bkmrk-this-is-will-get-stu">This is will get stuck for ever because the second parameter function will <strong>always fail</strong></p> <h2 id="bkmrk-system-dialog-functi"> <br><strong>System dialog functions</strong> </h2> <h3 id="bkmrk-setconfirmmessage">setConfirmMessage</h3> <p id="bkmrk-parameters%3A-messaged-1">Parameters: message<br>Description: Fills in message section of a confirm dialog<br>Example:</p> <blockquote id="bkmrk-setconfirmmessage%28%22t"> <p><code>setConfirmMessage("This is a message")</code> </p> </blockquote> <h3 id="bkmrk-setconfirmresponse">setConfirmResponse</h3> <p id="bkmrk-parameters%3A-booleand-2">Parameters: boolean<br>Description: Provide true if want system to automatically click the positive (OK, Yes) button of the confirm dialog<br>Example:</p> <img src="../../../Resources/Images/GeneralGraphics/Screen%20Shot%202022-01-31%20at%2003.28.09.png" id="bkmrk--9" alt="Screen%20Shot%202022-01-31%20at%2003.28.09.png"> <blockquote id="bkmrk-setconfirmresponse%28t"> <p><code>setConfirmResponse(true)</code> </p> </blockquote> <h3 id="bkmrk-getconfirmmessage">getConfirmMessage</h3> <p id="bkmrk-description%3A-returns-2">Description: Returns the confirm message set previously or "DS3_NOT_SET" if it has not been set.<br>Example:</p> <blockquote id="bkmrk-var-mess-%3D-getconfir"> <p><code>var mess = getConfirmMessage();</code> </p> </blockquote> <h3 id="bkmrk-setpromptresponse">setPromptResponse</h3> <p id="bkmrk-parameter%3A-string-wi">Parameter: string with prompt response<br>Description: Sets an automatic behavior with the default response for a system prompt dialog and closes it.<br>Example:</p> <blockquote id="bkmrk-var-mess-%3D-getconfir-1"> <p><code>var mess = getConfirmMessage();</code> </p> </blockquote> <h3 id="bkmrk-getpromptresponse">getPromptResponse</h3> <p id="bkmrk-description%3A-returns-3">Description: Returns the previously set default response string or "DS3_NOT_SET" if it has not been set.<br>Example:</p> <blockquote id="bkmrk-var-mess-%3D-getprompt"> <p><code>var mess = getPromptResponse();</code> </p> </blockquote>

Accessor Functions

Assert functions will always trigger a failure if they do not succeed. Verify Functions described above, unlike Assert functions, can be configure not to fail the script execution using the setAssertType function.

_byClassName = byClassName

Parameters: value
Description: Finds an element by class name with given tag name and constrained by given relations
Example:

<div class="bigfont">Some text</div>

_byClassName("bigfont", "DIV")

_byCss = byCss

Parameters: value
Description: This returns the element matching with the specified css
Example:

_navigateTo("http://sahitest.com/");
_click(_link("demo"));
_click(_byCss("a.a.x"));
_click(_link("Back"));

_byId = byId

Parameters: value
Description: This returns the element matching with the specified id
Example 1:

<div id="s2id_autogen2">Add Member</div>

_byId("s2id_autogen2") // points to the above tag. Note that the tagName "div" is not used here.

Example 2:

_navigateTo("http://sahitest.com/demo/linkTest.htm");
_click(_byCss("myLink"));


_byName = byName

Parameters: value
Description: Finds the element with the name of the element. If more than one match, this returns the first matching element.
Example:

navigateTo("http://sahitest.com/");
click(link("demo"));
click(link("Form Test"));
var t1 = byName("t1");

_byJQuery = byJQuery

Parameters: value
Description: Returns the first match based on the input string. Input can be any of jQuery selectors
Example:

byJQuery("#s1Id"); // id selector since u can see # in it
byJQuery("input"); // returns the first match input element
byJQuery(".ac-content"); // returns the first match of element class selector

_bySelenium = bySelenium

Parameters: value
Description: uses selenium locator to get the element
Example:

_navigateTo("http://sahitest.com/demo/");
_click(_bySelenium("css=a.a.x"));
_click(_link("Back"));

_byTagName = byTagName

Parameters: value
Description: Finds the element with the tag name of the element. If more than one match, this returns the first matching element.
Example:

navigateTo("http://sahitest.com/");
click(link("demo"));
click(link("Form Test"));
var text = byTagName("input");

_byXPath = byXPath

Parameters: value
Description: This returns the element matching with the specified XPath
Example:

navigateTo("http://demosite.appvance.com/");
click(byXPath('//*[@class="list-group-item"]'));
click(byXPath('//*[@class="list-group-item"]'));


Relational Accessor Functions

Relational accessor functions state that an element should be searched for in relation to another element, instead of by its own attributes. They make a locator more robust when the target element has no stable id, name, or text of its own — typically inside tables, menus, and repeated card layouts.

Summary

AccessorFinds the element…Typical use
_ininside another elementA link or label inside a specific container
_nearnearest to another element (by distance)An icon or button next to a known label
_aboveabove another elementA column header for a cell below it
_belowbelow another elementA value under a known header
_rightOfto the right of another elementThe cell beside a row label
_leftOfto the left of another elementThe row label beside a known cell

_in

Searches for the element within another element. Scope a generic locator to the region of the page where it is expected, which removes ambiguity when the same text or tag appears several times.

// the "Products" link that lives inside the /products link
click(span("Products", _in(link("/products"))));

_near

Searches for the element near another element. The accessor works from the centre point of the nearby elements and calculates the distance between the centre of the reference point and the surrounding objects in every direction.

The number written before near sets the order in which the system picks near objects: 0 is the nearest, 1 the second nearest, and so on.

// nearest element to the "Label Page" link
link(0, near("Label Page"));

// second nearest element to the same reference point
link(1, near("Label Page"));

_near and _below resolve positions with x/y coordinates, so they are the two accessors most sensitive to a changed page layout.

_above and _below

Searches for the element above or below another element. Both are most useful when working with tables, where the row label and the value share no attributes.

_above  strong("Type", _above(strong("Size")))
_below  strong("Size", _below(strong("Type")))

_rightOf and _leftOf

Searches for the element to the right or to the left of another element. Same syntax as the other relational accessors.

_rightOf  cell("Tote", _rightOf(strong("Type")))
_leftOf   strong("Type", _leftOf(cell("Tote")))

Example — all six accessors on one page

navigateTo("https://demosite.appvance.com/");
click(span("Ruby on Rails Tote"));

setDescription("Using in Relational Accessor");
click(span("Products", _in(link("/products"))));
click(span("Ruby on Rails Tote"));

setDescription("Using rightOf Relational Accessor");
assertExists(cell("Tote", _rightOf(strong("Type"))));

setDescription("Using leftOf Relational Accessor");
assertExists(strong("Type", _leftOf(cell("Tote"))));

setDescription("Using above Relational Accessor");
assertExists(strong("Type", _above(strong("Size"))));

setDescription("Using below Relational Accessor");
assertExists(strong("Size", _below(strong("Type"))));

Related: Accessor Functions, Fuzzy Logic and Regex Locators.

Navigation Functions

_disableMainFrame = disableMainFrame

Parameters:value
Description: disables main /parent page and selects the subframe inside the main frame
Example:

disableMainFrame();

_navigateTo = navigateTo

Parameters: URL
Description: loads the given URL in the top frame of the window. To load in a popup window, use _selectWindow to select that window first.
Example:

navigateTo("http://localhost:8080/UI/index.html");

_navigateToOrGet = navigateToOrGet

Parameters: URL
Description: loads the given host in the URL and then executes a GET HTTP call to the provided URL.
Example:

navigateToOrGet("https://www.synopsys.com/content/dam/synopsys/optical/pdf/RSoft-Choosing-Right-Photonic-System-Design-Software.pdf");

_prepareDomain = prepareDomain = _setDomain = _prepareDomain

Parameters: value
Description: DS3 prepares itself with any other external domain apart from the application domain to carry out actions in that.
Example:

prepareDomain("www.externaldomain.com"); //You can give any domain name thats external to current application whcih is under test.
prepareDomain("https://www.southwest.com"); // main site
prepareDomain("https://www.southwesthotels.com") // external domain.

_processScript = processScript

Parameters: script, method
Description: executes a given javascript file.
Example:

processScript("test/com/appvance/ds/api/Imported.js","js");

_setDomain = setDomain;

Parameters: value
Description: DS3 prepares itself with any other external domain apart from the application domain to carry out actions in that.

Both prepareDomain and setDomain are the same.

_selectFrame = selectFrame

Description: Used to restrict proxy commands to only iFrames that match the parameter. The string parameters check if the iframe id, href, class or text contains the provided parameter. See also selectMainFrame.
Example:

selectFrame("secondFrame"); //can select the frame by id,class,title,href,etc..

_selectMainFrame = selectMainFrame

Parameters:value
Description: Selects the Main DS3 Frame:
Example:

navigateTo("http://sahitest.com/demo/iframesTest.htm");
log(getIframesInfo());
selectFrame("[1]");
click(link("linkTest.htm"));
selectMainFrame();
click("Click me");

_selectWindow = selectWindow

Parameters: value
Description: Selects a window with title given to be current one.
Example:

navigateTo("http://sahitest.com/demo/iframesTest.htm");
log(getIframesInfo());
selectFrame("[1]");
click(link("linkTest.htm"));
selectMainFrame();
click("Click me");

_setSilenceAction = setSilenceAction


Parameters: boolean
Description: This causes the logging of the actions to stop or start. Does not affect the log action. Used together with startAction.
Example:

setSilenceAction(true);
navigateTo("http://www.sahitest.com");
startStep("My custom step name");
click(link("/demo"));
setSilenceAction(false);
click(link("a x[1]"));

_startStep = startStep


Parameters: step name
Description: This causes the log of a step with the given custom name. Used together with setSilenceAction.
See Also: setSilenceAction
Example:

setSilenceAction(true);
navigateTo("http://facebook.com");
startStep("Starting login")
setValue(texbox("email"),"abc@example.com");
setValue(textbox("password"),"acb12341!");
submit(button("login"));
setSilenceAction(false);

Assert Functions

Assert functions check a condition and record the result in the playback log. When the condition is false the step is reported as a failure, and what happens next depends on the assert type in effect: by default the script stops at that step (see Verify Functions for setAssertType and the Fail / FailAtEnd / Warning behaviours).

API summary

APIParametersFails when
assertExists(accessor)accessorthe element is not on the page
assertNotExists(accessor)accessorthe element is on the page
assertTrue(value)valuethe value evaluates to false
assertFalse(value)valuethe value evaluates to true
assertNull(value)valuethe value is not null
assertNotNull(value)valuethe value is null
assertEqual / assertEquals(A, B)A, Bthe two values are not equal
assertNotEqual / assertNotEquals(A, B)A, Bthe two values are equal
assertGreaterThan(first, second)first, secondfirst is not greater than second
assertLessThan(first, second)first, secondfirst is not lesser than second
assertGreaterOrEqual(first, second)first, secondfirst is not greater than or equal to second
assertLessOrEqual(first, second)first, secondfirst is not lesser than or equal to second
assertRange(number, min, max)number, min, maxthe number is outside the range
assertContains(fullText, snippet)fullText, snippetfullText does not contain snippet
assertDoesNotContain(fullText, snippet)fullText, snippetfullText contains snippet
assertContainsText(accessor, text)accessor, expected text or regular expressionthe element text does not contain the expected value
assertDoesNotContainText(accessor, text)accessor, expected text or regular expressionthe element text contains the expected value
assertTextPresent(accessor, text)accessor, expected textthe expected text is not present
assertTextNotPresent(accessor, text)accessor, expected textthe expected text is present
assertSelectHasOption(accessor, option)accessor, optionthe select has no such option
assertSelectMissingOption(accessor, option)accessor, optionthe select has that option

Never use an assert inside an if condition. Assert APIs return no value and throw an exception when they fail, so the branch cannot be evaluated. To decide a branch, use a value-returning API such as getText, getValue, getAttribute, getBrowserURL or isVisible, or switch to the verify equivalent.

Detailed reference and examples

The sections below list each assert API with its aliases, its description and a working example. The underscored form and the plain form are interchangeable — both are accepted in a script.

_assertExists = assertExists

Description:
Asset Exists will log the step in the playback logs when the element exists, it will log as a failure if the element does not exist.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://demosite.appvance.com/");
wait(1000);
focus(span("Products[1]"));
assertExists(span("Products[1]"));

_assertNotExists

Parameters: value
Description:
Assert Not Exists will log failures in the logs if the element does exist on the page. This assertion is to check if certain elements that we are looking for does not exist on the page.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://demosite.appvance.com/");
wait(1000);
assertNotExists(span("Products[1]"));
click(link("Clothing"));

_assertTrue = assertTrue

Parameters: value
Description: Assert True will log failures in the logs if the condition evaluates to false.
Example:

navigateTo("http://sahitest.com/demo/training/login.htm");
var val2=_isVisible(_bold("Sahi Training Site"));
assertTrue(val2);

_assertFalse = assertFalse

Parameters: value
Description:
Assert False will log failures in the logs if the condition evaluates to true.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://sahitest.com/demo/training/login.htm");
var val1=_getText(_bold("Sahi Training Site"));
assertDoesNotContainText(log(val1);
assertEqual(val1,"Sahi Training Site");
assertNotEqual(val1,"abc");
assertFalse("abc");
var val2=_isVisible(_bold("Sahi Training Site"));
assertTrue(val2);

_assertNull = assertNull

Parameters: value
Description:
Assert Null will log failures to the logs if the value is not null and will continue to playback if the value is null.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://sahitest.com/demo/training/login.htm");
assertExists(bold("Sahi Training Site"));
assertNull(null);

_assertNotNull = assertNotNull

Parameters: value
Description:
Assert Not Null will log failure in the logs if the value is null.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://sahitest.com/demo/training/login.htm");
assertExists(bold("Sahi Training Site"));
assertNotNull("Sahi Training Site");

_assertEqual = assertEqual = _assertEquals = assertEquals

Parameters: value1, value2
Description:
Assert Equal checks if the expected value is equal to the Actual value.
AssertEqual will log failures to the playback logs if the expected and actual values are not equal. It logs the step when the assertion passes in the logs section.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://demosite.appvance.com/");
click(span("Products[1]"));
assertEqual(span("Home[1]"),"Home");
click(link("Clothing"));

_assertNotEqual = assertNotEqual

Parameters: value1, value2
Description:
As the name suggests, Assert not equal expects the string to be not equal and logs failures in the playback logs when the Expected string matches with the actual string.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://demosite.appvance.com/");
click(span("Products[1]"));
assertNotEqual(span("Home[1]"),"Home");
click(link("Clothing"));

_assertContainsText = assertContainsText

Parameters: fullText, element
Description:
As the name suggests, assert contains text checks for a string in the target element and logs success or failure.
It will log the step details if the assertion passes else it logs as a failure if the expected string or reg-ex is not part of the text content of a given element with a proper explanation and stops the script playback.
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

navigateTo("http://demosite.appvance.com/");
click(span("Products[1]"));
assertContainsText("Home",span("Home[1]"));
click(link("Clothing"));

_assertDoesNotContainText = assertDoesNotContainText

Parameters: fullText, element
Description: assertContainsText will do nothing if the expected string/regex is not part of the text content of given element _assertContainsText will log failures to the playback logs if the expected string/regex is part of the text content of given element
Example:

navigateTo("http://demosite.appvance.com/");
click(span("Products[1]"));
assertDoesNotContainText(click(link("Clothing"));

Verify Functions

Verify functions check the same conditions as the assert functions, but they do not abort the script at the step. A failed verification is recorded, and what happens next is decided by the assert type set for the run.

setAssertType(value)

Sets the behaviour applied when an assert or verify fails. It applies to the rest of the script.

ValueBehaviour on failure
Fail (default)The script stops at the step that failed.
FailAtEndThe script keeps running and the execution is marked as failed once the whole script completes.
WarningOnly a warning is logged, the script continues, and the failure is not raised as an error.
setAssertType("Warning");   // collect all verification warnings and keep the script running
setAssertType("FailAtEnd"); // keep running, but fail the run at the end
setAssertType("Fail");      // default: stop at the failed step

Verify APIs

The verify set mirrors the assert set: every assert API has a verify equivalent with the same parameters, and it can be used anywhere a statement is accepted — including inside a branch or a loop, where an assert would stop the playback.

Assert APIVerify equivalentChecks that
assertTrue / assertFalseverifyTrue / verifyFalsea boolean is true / false
assertExists / assertNotExistsverifyExists / verifyNotExiststhe element exists / does not exist
assertEquals / assertNotEqualsverifyEquals / verifyNotEqualstwo values are equal / different
assertNull / assertNotNullverifyNull / verifyNotNulla value is null / not null
assertContainsTextverifyContainsTextan element contains the text or regular expression
assertDoesNotContainTextverifyDoesNotContainTextan element does not contain the text or regular expression
assertGreaterThan / assertLessThanverifyGreaterThan / verifyLessThana number is greater / lesser than another
assertRangeverifyRangea number falls between a minimum and a maximum

The reference also lists a Validate call alongside the verify APIs.

Example

navigateTo("http://demosite.appvance.com/");
wait(1000);

setAssertType("Warning");

verifyExists(span("Products[1]"));
verifyContainsText(span("Products[1]"), "Ruby");
verifyTrue(isVisible(link("Clothing")));

// the script continues even when one of the checks above fails,
// and the failures are reported with the run

Choosing between assert and verify

Related: Assert Functions, Assertions (function signatures).

Conditional Functions (if / elseif / else / while)

Conditional and loop functions let a Test Designer script make a decision at playback time instead of running a fixed line-by-line sequence. Use them to branch on what the application actually rendered, and to repeat a block of steps until a condition is met.

if / elseif / else / endif

Runs one of several statement blocks depending on which condition evaluates to true. Conditions are evaluated top to bottom and the first true branch wins.

if syntax

if (condition1)
    statement1
elseif (condition2)
    statement2
else
    statementN
endif

if parameters

ParameterDescription
conditionAny expression that evaluates to true or false. Build it with a value-returning API — see the rules below.
statementThe step or steps executed when that branch is taken. A branch may hold several statements; group them in a block { ... }.
elseOptional. Runs when none of the previous conditions was true.

if example

navigateTo("http://demosite.appvance.com/");
wait(1000);

var items = getText(_span("cart-items"));

if (items == "0")
    click(link("Ruby on Rails Tote"));
elseif (items == "1")
    click(link("View cart"));
else
    click(link("Checkout"));
endif

while / endWhile

Creates a loop that repeats a statement as long as the test condition evaluates to true. The condition is evaluated before each pass, so the body never runs if the condition is already false.

while syntax

while (condition)
    statement
endWhile

while parameters

ParameterDescription
conditionEvaluated before each pass. While it is true the body runs; when it becomes false, execution continues with the statement after endWhile.
statementExecuted on every pass. To run several statements inside the loop, group them in a block { ... }.

while example

navigateTo("http://demosite.appvance.com/");
wait(1000);

var page = 1;

while (page <= 3)
{
    click(link("Page " + page));
    wait(1000);
    page = page + 1;
}
endWhile

Rules and pitfalls

Never put an assert or verify API inside a condition. Those APIs return no value and throw an exception when the assertion fails, so an if built on one aborts the script instead of branching. To decide a branch, use an API that returns a value and compare it.

Value-returning APIReturns
getText()Visible text of an element
getValue()Current value of an input
getAttribute()Value of an element attribute
getBrowserURL()Current page URL
isVisible()true / false

Related: Assert Functions, Verify Functions.

HTTP-Level API Functions Reference

_get = get

Parameters: url
Description: Executes a GET HTTP call, and returns the HTTP response.
Example:

_prepareDomain("https://www.wikipedia.org");
var response = _get("/");
assertEqual(response.status,200);
assertEqual(response.headers.contentType.first,"text/html");
log("response.getDataString()"+response.getDataString());
assertContains(response.getDataString(),"wikipedia");

_createGet = createGet

Parameters: url
Description: creates an HTTP GET request object. The object can be used to add headers, and to execute it just need to execute an eval.
Example:

_setDomain("http://localhost:9090");
var myGet = _createGet("http://localhost:9090/ds/dyn/basic/echo");
myGet.addUpdateQueryAction("echo","?echo=4&data=7",false);
assertEqual("?echo=4&data=7", myGet.eval().toStringContent());

_createPost = createPost

Parameters: url
Description: creates an HTTP POST request object. The object can be used to add headers, and to execute it just need to execute an eval.
Example:

var myPost = createPost("https://appvancetest.service-now.com:443/api/now/ui/page_timing/7d9bd42f13e71b00ae43721a6144b0b5");
myPost.addHeader("Content-Type", "application/json");
myPost.addHeader("X-Requested-With", "XMLHttpRequest");
myPost.setContentType("application/json");
var resp = myPost.eval().getContentString();

_createPatch = createPatch

Parameters: url

Description: creates an HTTP POST request object. The object can be used to add headers, and to execute it just need to execute an eval.
Example:

var call = createPost("https://appvancetest.service-now.com:443/api/now/ui/page_timing/7d9bd42f13e71b00ae43721a6144b0b5");
call.addHeader("Content-Type", "application/json");
call.addHeader("X-Requested-With", "XMLHttpRequest");
call.setContentType("application/json");
var call = call.eval().getContentString();


_createPut = createPut

Parameters: url
Description: creates an HTTP PUT request object. The object can be used to add headers, and to execute it just need to execute an eval.
Example:

_setDomain("http://localhost:9090");
var call = _createPut("http://localhost:9090/ds/dyn/basic/echo?echo=4&data=7");
log(call.eval().toStringContent());

_createHead = createHead

Parameters: url
Description: creates an HTTP PUT request object. The object can be used to add headers, and to execute it just need to execute an eval.
Example:

_setDomain("http://localhost:9090");
var call = _createHead("http://localhost:9090/ds/dyn/basic/echo?echo=4&data=7");
log(call.eval().toStringContent());


_createOptions = createOptions

Parameters: url
Description: creates an HTTP PUT request object. The object can be used to add headers, and to execute it just need to execute an eval.
Example:

_setDomain("http://localhost:9090");
var call = _createHead("http://localhost:9090/ds/dyn/basic/echo?echo=4&data=7");
log(call.eval().toStringContent());


Functions used by AI processes

_pageStructure= pageStructure(validDomains, type)

Parameters:

Description: gets the current page Structure based on DS3 Page Structure.

Example:

addSmartTagsLibrary("demosite.stags");
var pageStructure = pageStructure("https://demosite.appvance.com","Smarttags");

_setCompatibility = setCompatibility

Parameters: boolean
Description: Enables the compatibility mode for sites that run in legacy Internet Explorer versions.

Internet Explorer is no longer supported browser in AIQ.
Example:

_setCompatibility(true);
_navigateTo("http://sahitest.com/");
_click(_link("demo"));

_getCompatibility = getCompatibility

Description:
Example:

_setCompatibility(true);
assertTrue(_getCompatibility());
_navigateTo("https://ApplicationURL");
_setValue(_textbox("user"), $UserName);
_setValue(_password("password"), $Password);
_click(_submit("Login"));
_click(_cell($PatientNumber));

if (var1 == "No data entered \nClick to view CRF") {
_click(_link("Logout"));
} else {
_click(_button(19));
_click(_link("Logout"));
}
_setCompatibility(false);
_assertFalse(_getCompatibility());




Last updated: June 05, 2024

If you have any feedback on this topic, please contact us at documentation@appvance.ai

Test Designer HTTP History Functions

<h3 id="bkmrk-_sethistory">_setHistory</h3> <p id="bkmrk-parameters%3A-valuedes">Parameters: value<br>Description: sets the history file which is a zip containing all requests.</p> <p id="bkmrk-example%3A">Example:</p> <blockquote id="bkmrk-fileclient-fs-%3D-new-"> <p><code>FileClient fs = new FileClient();</code> <br><code>fs.setHistory("test/com/appvance/ds/js/cecris/DSLog_NewPRF.zip");</code> </p> </blockquote> <h3 id="bkmrk-_replayhistory">_replayHistory</h3> <p id="bkmrk-description%3A-playbac">Description: playback the history file</p> <p id="bkmrk-example%3A-1">Example:</p> <blockquote id="bkmrk-_replayhistory%28%29%3B-_w"> <p><code>_replayHistory();</code> <br><code>_wait(2000);</code> <br><code>_navigateTo("</code>https://g-mmember-qa1.example.in/<code>");</code></p> </blockquote> <h3 id="bkmrk-_clearhistory">_clearHistory</h3> <p id="bkmrk-description%3A-clears-">Description: clears the history data</p> <p id="bkmrk-example%3A-2">Example:</p> <blockquote id="bkmrk-_clearhistory%28%29%3B-_st"> <p><code>_clearHistory();</code> <br><code>_stopHistory();</code> </p> </blockquote> <h3 id="bkmrk-_stophistory">_stopHistory</h3> <p id="bkmrk-description%3A-stops-p">Description: stops playing the history<br>Example:</p> <blockquote id="bkmrk-fileclient-fs-%3D-new--1"> <p><code>FileClient fs = new FileClient();</code> <br><code>try{</code> <br><code> fs.setHistory("test/com/appvance/ds/js/ppd/DSLog.zip");</code> <br><code> fs.replayHistory();</code> <br><code> fs.processJSFile("test/com/appvance/ds/js/ppd/getAttr.js");</code> <br><code>} finally {</code> <br><code> fs.clearHistory();</code> <br><code> fs.stopHistory();</code> <br><code>}</code> </p> </blockquote> <h3 id="bkmrk-_dontcheckforws">_dontCheckForWS </h3> <p id="bkmrk-parameters%3A-dns%2C-por">Parameters: DNS, port<br>Description: adds the domain and host to the list of domains that should not be checked for HTTPS connection.<br>Example:</p> <blockquote id="bkmrk-_dontcheckforws%28%22g-m"> <p><code>_dontCheckForWS("</code>g-mmember-qa1.copart.in<code>",443);</code><br><code>_dontCheckForWS("</code>cdn.polyfill.io<code>",443);</code><br><code>_dontCheckForWS("</code>smetrics.copart.com<code>",443);</code><br><code>_wait(10000);</code><br><code>_navigateTo("</code>https://g-mmember-qa1.copart.in/<code>");</code><br><code>_wait(1000);</code><br><code>_click(_div("AUCTIONS"));</code></p> </blockquote> <h3 id="bkmrk-_printassertions">_printAssertions </h3> <p id="bkmrk-parameters%3A-booleand">Parameters: boolean<br>Description: enables logging of assertions executed. Mainly used for debugging purposes.<br>Example:</p> <blockquote id="bkmrk-_printassertions%28tru"> <p><code>_printAssertions(true);</code> </p> </blockquote>