<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: SAP GUI Scripting - Is it possible to automatically test a custom (VBScript) recorder? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255683#M4589840</link>
    <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;daniel_mccollum&lt;/SPAN&gt; Thanks. That is a motive of hope. Tomorrow, I will do a simple attempt of play &amp;amp; record at same time, and do a feedback here.&lt;/P&gt;</description>
    <pubDate>Sun, 01 Nov 2020 19:25:13 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2020-11-01T19:25:13Z</dc:date>
    <item>
      <title>SAP GUI Scripting - Is it possible to automatically test a custom (VBScript) recorder?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaq-p/12255681</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I have created a custom VBScript which records the SAP GUI user actions, and saves them into a JSON file in a given format (that I use in another completely different custom program).&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;I'd like to write automatic tests to make sure there's no regression in the future, but I don't know if it's possible the way I think.&lt;/P&gt;
  &lt;P&gt;My idea is to:&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;Records SAP GUI user actions corresponding to all possible cases -&amp;gt; many reference JSON files&lt;/LI&gt;
   &lt;LI&gt;Create a custom program which reads all these JSON files, interprets them, play them using SAP GUI Scripting, and record them with my custom recorder at the same time.&lt;/LI&gt;
   &lt;LI&gt;In the end, the new JSON files should be the same as the reference JSON files&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;I didn't try to do it yet, but I'm suspicious about the possibility of play and record at the same time (I fear that the same session cannot be locked by two processes "play" and "record" at the same time).&lt;/P&gt;
  &lt;P&gt;Did somebody tried that already?&lt;/P&gt;
  &lt;P&gt;Thanks a lot.&lt;/P&gt;
  &lt;P&gt;Sandra&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 09:36:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaq-p/12255681</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-30T09:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAP GUI Scripting - Is it possible to automatically test a custom (VBScript) recorder?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255682#M4589839</link>
      <description>&lt;P&gt;I've been Debugging a session being played back , &amp;amp; when I find the root cause of the error I've started the recorder to record a snippet to insert into the logic,&lt;/P&gt;&lt;P&gt;I haven't done the science to know the boundaries, however there were occasional session terminations. It also was "playback paused" in effect during the recording due to the script being in debug. &lt;/P&gt;&lt;P&gt;That was down at 7.4 if I recall. Its probably better now, or the same at least &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 18:03:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255682#M4589839</guid>
      <dc:creator>daniel_mccollum</dc:creator>
      <dc:date>2020-11-01T18:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAP GUI Scripting - Is it possible to automatically test a custom (VBScript) recorder?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255683#M4589840</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;daniel_mccollum&lt;/SPAN&gt; Thanks. That is a motive of hope. Tomorrow, I will do a simple attempt of play &amp;amp; record at same time, and do a feedback here.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 19:25:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255683#M4589840</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-11-01T19:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAP GUI Scripting - Is it possible to automatically test a custom (VBScript) recorder?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255684#M4589841</link>
      <description>&lt;P&gt;Okay, "play and record" at the same time works. CC &lt;SPAN class="mention-scrubbed"&gt;daniel_mccollum&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;For information, my test VBScript that I debug at line "WScript.Quit 0" (dummy line) to watch the global variable "command":&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Dim command
Call Main
WScript.Quit 0

Sub Main()
If Not IsObject(oApplication) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set oApplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = oApplication.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject oApplication, "on"
End If

session.findById("wnd[0]").resizeWorkingPane 174,35,false

command = "[ {}" &amp;amp; chr(10)

Call WScript.ConnectObject(session,"sess")
session.record = True

session.findById("wnd[0]/tbar[0]/okcd").text = "/NSE38"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRS38M-PROGRAMM").text = "SAPCOLUMN_TREE_CONTROL_DEMO"
session.findById("wnd[0]/usr/ctxtRS38M-PROGRAMM").caretPosition = 27
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").selectItem "Child1","Column2"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").ensureVisibleHorizontalItem "Child1","Column2"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").pressButton "Child1","Column2"

Call WScript.DisconnectObject(Session)
session.record = False

command = command &amp;amp; "]" &amp;amp; chr(10)

End Sub

Sub sessChange(Session, Component, CommandArray)
  If Component Is Nothing Then
    ' Create Session
    Exit Sub
  End if
  length = 0
  For i = 0 To UBound(CommandArray)
    commandargument = getCommandArgument(CommandArray,i)
    componentType = getComponentType(component)
    command = command &amp;amp; ", { ""stepType"":""userCommand""" &amp;amp; ", ""userCommand"":" &amp;amp; jv(commandarray(i)(0) &amp;amp; ":" &amp;amp; commandarray(i)(1)) &amp;amp; ", ""componentType"":" &amp;amp; jv(getComponentType(Component))
    command = command &amp;amp; ", ""commandType"":""" &amp;amp; commandarray(i)(0) &amp;amp; "/" &amp;amp; componentType &amp;amp; "/" &amp;amp; commandarray(i)(1) &amp;amp; """ }" &amp;amp; chr(10)
  Next
End Sub

Function getCommandArgument(commandarray,i)
  On Error Resume Next
  lastIndex = UBound(commandarray(i))
  commandargument = ""
  If Err.Number &amp;lt;&amp;gt; 0 Then
    commandargument = commandargument &amp;amp; "ERR! " &amp;amp; Typename(commandarray)
    Exit Function
  End If
  commandargument = ""
  For j = 2 To lastIndex
    Err.Clear
    commandargument = commandargument &amp;amp; commandarray(i)(j) &amp;amp; ","
    If Err.Number &amp;lt;&amp;gt; 0 Then
      commandargument = commandargument &amp;amp; "ERR! " &amp;amp; Typename(commandarray(i)(j)) &amp;amp; ","
    End If
  Next
  getCommandArgument = commandargument
End Function

Function getComponentType(component)
  If component.type = "GuiShell" Then
    componentType = component.SubType
  ElseIf left(component.type,3) = "Gui" Then
    ' Gui should always be the first three characters
    componentType = Mid(component.type,4)
  Else
    ' Unexpected situation, keep the component type.
    componentType = component.type
  End If
  ' First letter lower case, except if second letter is upper case
  If Mid(componentType,2,1) = LCase(Mid(componentType,2,1)) Then
    getComponentType = LCase(Left(componentType,1)) &amp;amp; Mid(componentType,2)
  Else
    getComponentType = componentType
  End If
End Function

Function jv(value)
  jv = """" &amp;amp; replace(replace(replace(replace(replace(replace(value, "\", "\\"),"""","\"""),"/","\/"),chr(10),"\n"),chr(13),"\r"),chr(9),"\t") &amp;amp; """"
end function
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And so, now, if I write the variable "command" (JSON) to a file and I create a VBScript which reads the JSON file and converts it into SAP GUI Scripting commands, and records the screens at the same time, it should detect any regression in the recorder.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 13:04:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255684#M4589841</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-11-04T13:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAP GUI Scripting - Is it possible to automatically test a custom (VBScript) recorder?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255685#M4589842</link>
      <description>&lt;P&gt;delightful! &lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 19:49:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-gui-scripting-is-it-possible-to-automatically-test-a-custom-vbscript/qaa-p/12255685#M4589842</guid>
      <dc:creator>daniel_mccollum</dc:creator>
      <dc:date>2020-11-04T19:49:54Z</dc:date>
    </item>
  </channel>
</rss>

