Troubleshooting
Problem
This technote presents a code example for a message box from a Visual Basic script (VBS). The IBM® Rational® Robot GUI script retrieves the text output of this VBS and stores the output's content into a Robot script variable.
Resolving The Problem
The following script retrieves the two text lines from VBS message box. The VBS is the following script:
| MsgBox "Hello World " & VbCrLF & "and goodbye", 0, "MyMessage" |
The output is the message box in figure 1.

Figure 1: output from the Visual Basic Script.
First you record a case-sensitive alphanumeric verification prompt. Then you declare a function AlphaVPString. The actions of this function are:
- The function determines the location of the baseline file.
- The function opens the baseline file.
- The function reads all lines and append the lines content into a variable.
- The function closes the baseline file.
You can do with the variable whatever is possible in Robot scripting. The result is the following Robot script. In this case the script sends the content to the Robot console.
Declare Function AlphaVPstring(VPname As String) As StringSub Main Dim Result As Integer 'start the Visual Basic script Shell("wscript c:\temp\HelloWorld.vbs") Window SetTestContext, "Caption=MyMessage", "" Result = LabelVP (CompareText, "Text=Hello World and goodbye", _ "VP=Prompt;Wait=1,10;Type=CaseSensitive") Window ResetTestContext, "", "" Window SetContext, "Caption=MyMessage", "" PushButton Click, "Text=OK" SQAConsoleWrite (AlphaVPstring("Prompt")) End Sub Function AlphaVPstring(VPname As String) As String Dim ret As String Dim content As String Dim fullContent Const txt As String = "txt" ret = SQAVpGetCurrentBaselineFileName(VPname, txt) Open ret For Input As #1 If fileLen(ret) > 0 Then Do Line Input #1, content fullContent = fullContent & content Loop Until EOF(1) End If Close #1 AlphaVPstring = fullContent End Function |
After playback the Robot console shows the following output in a single line:
Hello World and goodbye
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21312707