Quantcast
Channel:
Viewing all articles
Browse latest Browse all 43889

Wiki Page: Tips on how to use SilkTest to work with a calendar?

$
0
0
  There is no full support for SilkTest to work with a calendar as there can be several different technologies used to develop calendars (e.g. JavaScript in the below example). Calendar objects in Browsers are usually only seen as HtmlText objects. The Main issue encountered when working with a calendar is dynamic tag information on the calendar objects - this is because the calendar"s contents can constantly change. This can be compensated for by dynamically scripting actions against the calendar objects. In a JavaScript calendar, this mainly occurs when the SilkTest option ShowHtmlTable is disabled . With this option enabled , we can specify the day and date we want to click as follows: JavaScriptCalendar.HtmlTable( "Zapatec Javascript Calendar" ).HtmlColumn( "*|{ sToday }|*" ).HtmlText( "*|{ sDate }|*" ).Click( 1 , 10 , 10 ) However, in an application where the SilkTest option ShowHtmlTable has to be disabled this will result in dynamic tag information constantly being generated when the calendar is reloaded. This can be worked around as follows: Ensure it is possible to capture the windows declarations of the calendar at runtime using the example in article How can I create a method which can be used to tag a dynamic object at runtime? . STRING GetDynamicTag( WINDOW wObj) STRING sOutput, sTag LIST OF STRING lsDecl // Generate the declarations of the page/window at runtime lsDecl = wObj.GenerateDecl() The above function takes a window object and generates the windows declaration of the window containing this object. Store this information in a text file for use during test run. // Pass the runtime declarations to a text file if (SYS_FileExists(sFileName)) // ListWrite(lsDecl, sFileName) // The parameters to the function below are the file holding the declarations, the identifier of the object you wish to tag and the output string variable if !(SYS_FileExists(sFileName)) ListWrite(lsDecl, sFileName) Use a GetObjTag(STRING sFile, STRING sDate, STRING sMatchItem, out STRING output) function which takes the parameters file path, a specified date, an object identifier and will return object tag information as output. GetObjTag(sFileName, sDate, sIdentifier, sOutput) The returned value is the tag information for the specified object (i.e. [+] multitag "1[1]"). Using GetField function, we only need the tag information which will be stored in a string value. sTag = GetField(sOutput, "{ Chr( 34) }" , 2 ), result of this returns 1[1] Now use the above tag information to call a click method on a HtmlText object on the calendar to click on a specified date. JavaScriptCalendar.HtmlText( "*|{ GetDynamicTag(wObj, sDate, sObjIdentifier+sDate) }|*" ).Click( 1 , 10 , 10 ) sObjIdentifier is a constant which identifies the object being focused on. In this case "HtmlText N" is always the prefix of all dates on the calendar used in this resolution. sDate is the specified date to click, so concatenating the two strings results in the full object identifier to search for in the windows declaration. If the user want to click on 5, when concatenated, the result is "HtmlText N5". This is the object identifier. The search in the declaration text file finds this item, then reads the next line which is always the object"s tag information. This is what is return as [+] multitag "5[1]". GetField is used to get 5[1] and this is what we reference when we call the click method above. JavaScriptCalendar.HtmlText( "*|5[1]|*" ).Click( 1 , 10 , 10 ) A working example is attached in Calendar.zip. Note: The attached project will handle most calendars, be sure to modify the conditional statements in GetObjTag.inc if previous month or next month dates that appear in current month differs from the selected (Val(sVal) = 24). Related documents: How can I create a method which can be used to tag a dynamic object at runtime? Old KB# 23605

Viewing all articles
Browse latest Browse all 43889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>