I am pasting one sample script which runs very slow on a perticular machine but is very fast in other machines. I am unable to find the exact command where the exception occurs as the exception always goes in the catch block.... Although exception is not the major issue and is not always seen but the script execution becomes very slow and the script return false as it becomes unable to find the target object alhough is on the screen and the same script runs perfect in other system.
Is there any settings issue in test complete. Web testing plugin is present there.
// Function CreateGUIAccount : To click on the Panel Header buttons on the DVS GUI
// Arguments : 3
// 1. userName: New User Name to be created eg: admin
// 2. userPerm : Permission of the user to be assigned eg: superadmin
// 3. userPwd : Password for the new User. eg:Password
// Returns true if the account is created successfully else returns false
function CreateGUIAccount ( userName, userPerm, userPwd )
CreateGUIAccount ( userName, userPerm, userPwd )
{
try
{
var page=Sys.Process("iexplore").Page("*");
var createAccountBtnXpth="//DIV[@id='settingsContainer']//DIV[@id='settingsAdminAccounts']//DIV[@class='SettingsAccounts']//SPAN[@class='capabilities-block cap-admin-user-add vacButtonContainer']//BUTTON";
var userCredTxtBxXpth="//DIV[@id='add_user_dialog']//TABLE[@class='TableFirewallPolicy']//INPUT";
var buttonsXpth="//DIV[@id='add_user_dialog']//DIV[@class='dialogButtonContainer']//BUTTON";
if(!ClickPanelTab(DvsPanelTabList.Settings))
return false;
if (! ClickSettingsTabList(SettingsTab.AdministrativeAccounts) )
return false;
//Get the button to create user
createAccountBtn = ReturnXPathObjects(createAccountBtnXpth);
if(createAccountBtn == null)
{
Log.Message("Create account button not found");
return false;
}
if(!createAccountBtn[0].VisibleOnScreen)
{
Log.Message("Create user button not enabled");
return false;
}
createAccountBtn[0].Click();
//Get the table containing Snap Shot
userCredTxtBx = ReturnXPathObjects(userCredTxtBxXpth);
if(userCredTxtBx == null)
{
Log.Message("Text box for entering new users credentials not found");
return false;
}
//Enter the user name
userCredTxtBx[0].setText(userName);
//Enter Privilege
userCredTxtBx[1].setText(userPerm);
//Enter Password
userCredTxtBx[3].setText(userPwd);
//Re-enter password
userCredTxtBx[4].setText(userPwd);
//Get the object of both the buttons
buttons = ReturnXPathObjects(buttonsXpth);
if(buttons == null)
{
Log.Message("Add User/Cancel buttons not found");
return false;
}
//Click on Add user button
buttons[0].Click();
page.wait();
//Wait for the error message to appear
if(page.Panel("net_error_dialog").WaitProperty("Visible", true, 15000))
{
if(!page.Panel("net_error_dialog").WaitProperty("Visible", false, 20000))
{
return false;
}
}
//Check whether the user is created
if(FindUser(userName, userPerm))
{
return true;
}
return false;
}
// Catch and log exception if any and return false
catch ( exception )
{
Log.Warning("Exception: "+ exception.description);
return false ;
}
}
//Function to find the user from the table
//Accepts 2 arguments
// arg1: User Name
// arg2: user Permission
//Return true if the user is found
function FindUser(userName, userPerm)
FindUser(userName, userPerm)
{
try
{
var page=Sys.Process("iexplore").Page("*");
var usersTableXpth="//DIV[@id='settingsAdminAccounts']//DIV[@class='SettingsAccounts']//TABLE[@id='Accounts']";
var rowCount;
for(index = 0; index < 3; index ++)
{
//Get the web object of the button
usersTable = ReturnXPathObjects(usersTableXpth);
if(usersTable != null)
{
break;
}
}
if(index == 3)
{
Log.Message("User table not found");
return false;
}
//Get the number of rows in the table
rowCount=usersTable[0].RowCount;
Log.Message(rowCount);
for(count=0; count<rowCount; count++)
{
if(aqString.Find(usersTable[0].Cell(count, 0).outerText, userName, 0, true)!= -1)
{
if(aqString.Find(usersTable[0].Cell(count, 1).outerText, userPerm, 0, true) != -1)
{
return true;
}
}
}
return false;
}
catch(exception)
{
Log.Warning(exception.description);
return false;
}
}