Skip to main content

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>