cancel
Showing results for 
Search instead for 
Did you mean: 

Keyword Test - Get new Id value from textbox

SOLVED
Highlighted
mac
Occasional Contributor

Keyword Test - Get new Id value from textbox

I apologize ahead of time in case the answer to my question should be obvious.  I have not been able to find it.

 

I want to run a desktop app that creates a new widget.  Once the widget is saved, the new Id appears in a textbox.  I want to get the Id from this textbox and save it in a csv file to use as input to another test.

 

Recording the test works great.  How do I hook to the textbox, get the value from it, and write it to a file?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Keyword Test - Get new Id value from textbox

So, you're doing a Keyword test.

 

Well, what you're going to want to do is use a Set Variable operation to create and set a variable to equal to a property value.  In that operation, you'll select, for the value, an Onscreen Object Property and then use the picking control to grab the object and find the appropriate property.

 

Writing out to a file is a bit trickier, I'm afraid.  There is a "Save to File" operation but I think that would overwrite the file every time rather than append to it.  

 

So, instead, use the "Call Object Method" operation and find the aqFile object.  Then use the WriteToTextFile method and fill in the appropriate parameters as per https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/writetotextfile.htm...

 

The "String" would be the variable that you created with the content.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

3 REPLIES 3
Community Hero

Re: Keyword Test - Get new Id value from textbox

So, you're doing a Keyword test.

 

Well, what you're going to want to do is use a Set Variable operation to create and set a variable to equal to a property value.  In that operation, you'll select, for the value, an Onscreen Object Property and then use the picking control to grab the object and find the appropriate property.

 

Writing out to a file is a bit trickier, I'm afraid.  There is a "Save to File" operation but I think that would overwrite the file every time rather than append to it.  

 

So, instead, use the "Call Object Method" operation and find the aqFile object.  Then use the WriteToTextFile method and fill in the appropriate parameters as per https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/writetotextfile.htm...

 

The "String" would be the variable that you created with the content.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

mac
Occasional Contributor

Re: Keyword Test - Get new Id value from textbox

Robert,

I have followed your instructions and the test executes without an error.  If I put a breakpoint on the line which calls "aqFile.WriteToTextFile" I can see the correct value in variable "EventId."  However, the value of the new EventId is not getting written to the file.  Please take a look and tell me where I am missing something.

 

Sub Test2()
Dim EventId
EventId = ""
'Runs the "SwitchingManager" tested application.
Call TestedApps.SwitchingManager.Run
'Clicks the 'btnNew' button.
Call Aliases.SwitchingManager.frmSwitchingManagerMain.ucTransEventSummaryDisplay.pnlActionButtons.btnNew.ClickButton
'Clicks the 'btnCreatePlannedOutage' button.
Call Aliases.SwitchingManager.frmCreateEvent.flpButtons.pnlCreatePlannedOutage.btnCreatePlannedOutage.ClickButton
'Selects the 'Alfermann Tap' item of the 'cboLocation' combo box.
Call Aliases.SwitchingManager.frmTransEventDetail.ucPlannedOutageDetailPanel.pnlControls.cboLocation.ClickItem("Alfermann Tap")
'Clicks at point (194, 15) of the 'txtReason' object.
Call Aliases.SwitchingManager.frmTransEventDetail.ucPlannedOutageDetailPanel.pnlControls.txtReason.Click(194, 15)
'Enters the text 'test' in the 'txtReason' text editor.
Call Aliases.SwitchingManager.frmTransEventDetail.ucPlannedOutageDetailPanel.pnlControls.txtReason.SetText("test")
'Clicks at point (187, 13) of the 'txtEquipmentNotes' object.
Call Aliases.SwitchingManager.frmTransEventDetail.SplitContainer1.SplitterPanel.pnlScrollableContent.ucPlannedOutageEquipmentPanel.pnlControls.txtEquipmentNotes.Click(187, 13)
'Enters 'test' in the 'txtEquipmentNotes' object.
Call Aliases.SwitchingManager.frmTransEventDetail.SplitContainer1.SplitterPanel.pnlScrollableContent.ucPlannedOutageEquipmentPanel.pnlControls.txtEquipmentNotes.Keys("test")
'Selects the 'Out of Service' item of the 'cboProtectionType' combo box.
Call Aliases.SwitchingManager.frmTransEventDetail.SplitContainer1.SplitterPanel.pnlScrollableContent.ucPlannedProtectionAndGroundingPanel.pnlControls.cboProtectionType.ClickItem("Out of Service")
'Clicks the 'Save' item of the 'tsTransEventActions' bar.
Call Aliases.SwitchingManager.frmTransEventDetail.ucTransEventActionToolbar.pnlControls.tsTransEventActions.ClickItem("Save")
'Gets the new value in txtEventId
EventId = Aliases.SwitchingManager.frmTransEventDetail.ucEventHeaderPanel.pnlControls.txtEventId.Text
'Writes the specified string to a text file.
Call aqFile.WriteToTextFile("file.txt", EventId, 22, True)
'Closes the 'frmTransEventDetail' window.
Call Aliases.SwitchingManager.frmTransEventDetail.Close
'Closes the 'frmSwitchingManagerMain' window.
Call Aliases.SwitchingManager.frmSwitchingManagerMain.Close
End Sub

mac
Occasional Contributor

Re: Keyword Test - Get new Id value from textbox

Found my error.  Very stupid.  I didn't specify the whole path to the file.  Should have been "C:\temp\file.txt"