Ask a Question

Using TestComplete script to access ToolBar in Orders Sample

Zels
New Contributor

Using TestComplete script to access ToolBar in Orders Sample

I am new to TestComplete so I am learning using the "Orders" code example.

I am trying to access the file open in the toolbar from the Orders example.  Using these python commands, I think that I can get to the toolbar:
p = Sys.Process("Orders")
w1 = p.WinFormsObject("MainForm")
toolBar = w1.WinFormsObject("ToolBar")

 

I am trying to figure out how to get access to the buttons now, I think the command :

toolBar.Buttons[1] 

gets me to the file open button, but I am at a lost at what to do next.

 

Thank you for any ideas.

2 REPLIES 2
AlexKaras
Champion Level 2

Hi,

 

I think that the following approach might be helpful:

-- Plan some actions over tested application;

-- Record script (or keyword test);

-- Go through recorded code and try to understand it;

-- Try to replay generated code. Use https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/index.html and https://support.smartbear.com/testcomplete/docs/testing-with/running/messages/index.html help sections to resolve possible playback problems/instability;

-- Try to enhance or extend generated code (add logging, some parameterization, etc.);

-- Try to execute modified code.

 

Repeat the above process several times to get better understanding of how TestComplete works with tested application. Try to read for details about NameMapping and Aliases (https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/inde...) and understand how this piece of functionality works.

 

Try to use the obtained knowledge to craft test code that you actually need for your real tested application. Actually, you may start with small basic steps: e.g. create test that will reliably start your tested application and another test that will reliably close it. Even with these two basic tests you may check that new build of your tested application can be started and closed as expected.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
Zels
New Contributor

Figured it Out.

 

#@FirstScript
def FirstTestScript():
  p = Sys.Process("Orders")
  w1 = p.WinFormsObject("MainForm")
  toolbar = w1.WinFormsObject("ToolBar")
  toolbar.ClickItem(1)
  Sys.Process("Orders").Window("#32770", "Open", 1).OpenFile("MyTable.tbl")
 
#End of FirstScript
cancel
Showing results for 
Search instead for 
Did you mean: