cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with JScript referencing of application windows

Highlighted
Not applicable

Problems with JScript referencing of application windows

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 12" name="Generator" />
<meta content="Microsoft Word 12" name="Originator" />





I am having difficulties recording test scripts in jscript
in certain areas of the application that I am trying to test.  However, I find I do not have the same
difficulties if I record in vbscript.  


The example below covers some simple functionality as
follows: The File->Open option is taken from the application menu, a ‘New
Study’ button is selected on the resulting Open dialog box. Then a new ‘Create
new study’ dialog box is displayed on which the study name is entered. Pressing
Ok causes the study tree to be created.




The main issue seems
to be that the jscript script is not able to distinguish between my two dialog
boxes, whereas the vbscript script can.  I have tried to alter the scripts, but the available structures when I
am running in Jscript do not seem to cater for the second window.  Can you
give me some guidance as to what the issue may be here? I would really prefer
to use jscript rather than vbscript for my scripting if at all possible.


In VBScript my recorded script is as follows


 


Sub Test4


' Create new study from Open / New Study button


  Dim
OCDSClient_OCDSStudyManager


  Dim frmMain


  Dim
frmCreateNewStudy


  Dim
textEdit


  Dim
groupControl


  Set
OCDSClient_OCDSStudyManager = Aliases.OCDSClient_OCDSStudyManager


  Set frmMain
= OCDSClient_OCDSStudyManager.frmMain


  ' Select File Open menu option


  Call
frmMain.StripMainMenu.Click("File|Open")


 


  ' Select New Study button from resulting Open Study dialog
box


 
OCDSClient_OCDSStudyManager.frmOpenStudyOptionDialog.NewStudyButton.ClickButton


  Set
frmCreateNewStudy = OCDSClient_OCDSStudyManager.frmCreateNewStudy


 


  ' In Create New Study dialog box enter new study name and
choose to create empty study. Then press OK


  Set
textEdit = frmCreateNewStudy.StudyNameTextEdit


  textEdit.wText =
"MK A New Empty Study 3"


  Set
groupControl = frmCreateNewStudy.GroupControl1


 
groupControl.CreateEmptyStudyRadioButton.ClickButton


 
frmCreateNewStudy.OKButton.ClickButton


 


  ' Now click on Study tree to check that it has been
created


  Call
frmMain.DockSite1.leftBar1.UCStudyExplorer.StudyExplorerPhysTreeView.ClickItem("|MK
A New Empty Study 3")


  Call aqObject.CompareProperty(Aliases.OCDSClient_OCDSStudyManager.frmMain.DockSite1.leftBar1.UCStudyExplorer.StudyExplorerPhysTreeView.wSelection,
cmpEqual, "|MK A New Empty Study 2", False)


End Sub


 


In Jscript, the similar script comes out like this:


 


function
Test2()


{


      var  toolbarWindow32;


      var  OCDSClient_OCDSStudyManager;


      var  frmMain;


      var  frmOpenStudyOptionDialog;


      var  textEdit;


      var  textBoxMaskBox;


      var  groupControl;


      OCDSClient_OCDSStudyManager
= Aliases.OCDSClient_OCDSStudyManager;


      frmMain =
OCDSClient_OCDSStudyManager.frmMain;


  // Select File-Open option from menu


      frmMain.StripMainMenu.Click("File|Open");


  // Select New Study button from resulting Open Study
dialog box


      frmOpenStudyOptionDialog
= OCDSClient_OCDSStudyManager.wndWindowsForms10Window8app0129c866;


      frmOpenStudyOptionDialog.NewStudyButton.ClickButton();


 


  // In Create New Study dialog box enter new study name and
choose to create empty study. Then press OK


      textEdit =
frmOpenStudyOptionDialog.StudyNameTextEdit;


      textEdit.wText
= "MK MK Test Empty Study";


      groupControl =
frmOpenStudyOptionDialog.GroupControl1;


      groupControl.CreateEmptyStudyRadioButton.ClickButton();


      frmOpenStudyOptionDialog.OKButton.ClickButton();


 


  // Now click on Study tree to check that it has been
created


      frmMain.DockSite1.leftBar1.UCStudyExplorer.StudyExplorerPhysTreeView.ClickItem("|MK
MK Test Empty Study");


      aqObject.CompareProperty(Aliases.OCDSClient_OCDSStudyManager.frmMain.DockSite1.leftBar1.UCStudyExplorer.StudyExplorerPhysTreeView.wSelection,
cmpEqual, "|MK MK Test Empty Study", false);


}


 


1 REPLY 1
Highlighted

Hello Maeve,




Actually, the object recognition and script recording functionality of TestComplete is the same for all scripting languages. So, the problem you are having is not related to the scripting language you are using. Feel free to use JScript if you like it.




The scripts you posted are almost identical in the sense of functionality, but there is one line in the JScript version of the test that indicates a problem:

>>>      frmOpenStudyOptionDialog = OCDSClient_OCDSStudyManager.wndWindowsForms10Window8app0129c866;




Mapped names like "wndWindowsForms10Window8app0129c866" can be given to a window of a .NET application when the application is not recognized as Open by TestComplete for some reason. Taking into account that the problem is not persistent, I would assume this is a timing problem - the tested application sometimes gets busy for a long time and TestComplete cannot initialize its .NET Open Applications engine for this application. If my assumption is correct, increasing the value of the "Open Applications | General | Method invoke timeout" setting of your project should solve the problem.




So, delete the "wndWindowsForms10Window8app0129c866" object from the Name Mapping tree and record your test anew.

If you face some problems with this, let me know.

-----

Alexander
Customer Care Manager
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors