TestLab

  Home / Services
Services
Our Services
Software Testing Process
Functional Testing
Configuration Testing
Performance Testing
Software Testing Tools
Automated Testing
Security Testing
Installation Testing
Regression Testing
Script Examples - Automated QA TestComplete
Script Examples - Selenium

     

Script Examples - Automated QA TestComplete

Script Examples

 
This script was developed by QATestlab team in order to test desktop .Net application with the help of TestComplete (Automated QA).

The script imports orders in *.txt format to desktop application and verifies behavior in different test situations.

Sample Script for TestComplete

//Import two identical files (orders)

function Import_Identical_Order()

{

// p – process

// w – window

  var  p1;

  var  w1,w2,w3,w4;

  var l1;

  var i=0;

  p1 = Sys.Process("ClientCatalog");

  w1 = p1.MainForm;

 //Choose Electric tools in tree

  w1.WinFormsObject("panelTreeView").treeViewElements.

  ClickItem("|Catalogues|   Electric tools|");

 

   //Clear order with clear button

    Clear_Order();

 

  w1.MainMenu.Click("Import Order");

 

// Dialogue Windows

  var oOpenDlg = p1.Window("#32770",

  "Import Order from File”);

  if (!oOpenDlg.Exists)

    throw "Open dialog not found!";

   

 

  oOpenDlg.Window("ComboBoxEx32", "", 1).

  Keys(Project.Path + "Filesorder.txt");

  oOpenDlg.Window("Button", "&Open").ClickButton();

 

 

// Wait order processing

  while (g2.gradIconicButtonForm.Enabled!=true)

delay(100);

 

w1.WinFormsObject("panelTreeView").

treeViewElements.ClickItem

("|Catalogues|   Electric tools|");

 

w2=w1.WinFormsObject("panelCBottom").

WinFormsObject("CatalogsBottom").

WinFormsObject("panelCatalogs");

 

// verify

Find_Picture(w2, "Import_Correct_Order_001.jpg");

 

 

// Repeat import - Cancel

 

  w1.MainMenu.Click("Import Order");

 

// Dialogue Windows

  var oOpenDlg = p1.Window("#32770", "Import Order from File”);

  if (!oOpenDlg.Exists)

    throw "Open dialog not found!";

   

 

  oOpenDlg.Window("ComboBoxEx32", "", 1).

  Keys(Project.Path + "Filesorder.txt")

  oOpenDlg.Window("Button", "&Open").ClickButton();

 

 

 

  w3=p1.WaitWinFormsObject

("ImportOrderConfirmation", 100000);

  

 

  if (w3.Exists)                                        

   {

   l1=w3.WinFormsObject("labelText")

   if (l1.Text!="Current order contains goods.")

      Log.Error("Wrong message")

  //Cancel

   w3.WinFormsObject("gradIconicButtonCancel").

   ClickButton();

  

   }

  else

  Log.Error("Wrong message after import identical order");

 

  if (w3.Exists)                                        

     Log.Error("Error"); 

 

 

// Repeat import – addition to order

 

  w1.MainMenu.Click("Import Order");

 

// Dialogue Windows

  var oOpenDlg = p1.Window("#32770", "Import Order from File”);

  if (!oOpenDlg.Exists)

    throw "Open dialog not found!";

   

 

  oOpenDlg.Window("ComboBoxEx32", "", 1).

  Keys(Project.Path + "Filesorder.txt")

  oOpenDlg.Window("Button", "&Open").ClickButton();

 

 

 

  w3=p1.WaitWinFormsObject("ImportOrderConfirmation", 100000);

  

 

  if (w3.Exists)                                        

   {

   l1=w3.WinFormsObject("labelText")

   if (l1.Text!=" Current order contains goods.")

      Log.Error("Wrong message");

 

   // addition to order  

w3.WinFormsObject("gradIconicButtonAddOrder").

ClickButton();

  

w4=p1.WaitWinFormsObject("GradMessageBox", 100000);

 

 

 Log.Message

("Test ‘Import two identical files (orders) finished");

 

}

 


 
{rs:MEMBER_HITECH} {rs:UOF_SPONSOR}