Ask a Question

testComplete 14.20 + cannot access the user defined function

SOLVED
nisgupta
Valued Contributor

testComplete 14.20 + cannot access the user defined function

TestComplete 14.20 is having issues in calling the user defined functions.  I am running the 2 scripts. script 1 runs and it has errors which is expected and so the script stops and now when it pick up the second script and when it tried to call the functions it give the error "cannot ready property 'logCredentials' of undefined . testcomplete 14.10 do not have such issue. the script which was created in the older version works fine. 

S

34 REPLIES 34
Marsha_R
Community Hero

These are new scripts that are created in 14.2 or were they created in 14.1 and now you are trying to run them in 14.2?


Marsha_R
[Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
AlexKaras
Community Hero

Hi,

 

Scripting language?

Code example?

Does https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/declared-in-another-unit/... help?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tristaanogre
Esteemed Contributor

It would help if you shared your code.

However... the error message you indicated seems to be, as mentioned, a problem in reference.  you're calling some sort of method of "logCredentials" off of some other object, presumably a script unit, that doesn't exist or is not referenced properly.  We can't say for sure... we don't know what code is generating the error.

 

Double check the information shared by @AlexKaras and @Marsha_R  and, perhaps, share your code and we can help you more.


Robert Martin
[Hall of Fame]
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

@Marsha_R 

When creating brand new project suite in 14.20 we are getting the errors. Even I copied the project suite created in 14.10 then also it is giving the errors in 14.20. 

 

@tristaanogre 

What information do you need ? Do you want me to attach the whole project suite as I have only one project in the project suite .

 

tristaanogre
Esteemed Contributor

We don't need the whole suite... just copy/paste the code from the two units here that is giving you the problem.


Robert Martin
[Hall of Fame]
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

Here is the main Script.

 

var BrowserConfig = require("BrowserConfig");
var GeneralFuncs = require("GeneralFuncs");
var LoginCredentials = require("LoginCredentials");
var ReportLog = require("ReportLog");

 

 

function test_NBAPBUD_Status(){
// var tile = Aliases.browser.pagePYEmployeeOTP.textnodeLbltitle;
var welcome_searchTextBox = Aliases.browser.pageApplicationNavigator.textboxSearchLanding;
var titlePage = Aliases.browser.pageApplicationNavigator.frameBannerhs.textnodePositionBudgetNBAPBUD
// var logOut =
var expectedTitle = "Position Budget NBAPBUD 9.3.6 (UDEV) (HSC)";
var close = Aliases.browser.pageApplicationNavigator.frameBannerhs.linkCloseCtrlQ;
// var signInPage =
// var eraider =

BrowserConfig.killProcess("iexplore");
BrowserConfig.killProcess("firefox");
BrowserConfig.killProcess("chrome");



LoginCredentials.logCredentials(btFirefox,Project.Variables.baseURL);
aqUtils.Delay(5000);

//GeneralFuncs.selectsearchDropDown1(welcome_searchTextBox, welcome_searchTextBox,"NBAPBUD",Aliases.browser.pageApplicationNavigator.linkSearchanchorNoresult);
GeneralFuncs.EnterTextBoxValue(Aliases.browser.pageApplicationNavigator.textboxSearchLanding, "NBAPBUD");
aqUtils.Delay(2000);
Aliases.browser.pageApplicationNavigator.textboxSearchLanding.Keys("[Enter]");
aqUtils.Delay(5000);

// LoginCredentials.logCredentials(btFirefox, "https://ban8-udevbanapps.tosm.ttu.edu/itis/PY_Employee_OTP/Welcome.aspx");
//check the title of the page
// Log.Picture(Aliases.browser.pageApplicationNavigator.frameBannerhs, "The Title of the Page: ");
//aqObject.CheckProperty(Object, Property, Condition, Value, CaseSensitive)
Log.Message("Title is " + aqObject.CheckProperty(titlePage, "contentText", cmpEqual,expectedTitle));
Log.Message("The title of the Page: ");
GeneralFuncs.CheckText(titlePage);
// Log.Picture(Aliases.browser.pageApplicationNavigator.frameBannerhs, );
// var test = aqString.Compare(Aliases.browser.pageApplicationNavigator.frameBannerhs.textnodePositionBudgetNBAPBUD.contentText, expectedTitle, false);
//Log.Message(test);


aqUtils.Delay(5000);
//Wait for the page for another 5000 milliseconds
//aqUtils.Delay(5000);
GeneralFuncs.selectTab(close,close.title);
aqUtils.Delay(5000);
BrowserConfig.closeBrowserAfterTestRun();
//Kill the firefox process
BrowserConfig.killProcess("firefox");

}

 

 


/**
function logCredentials(){
var username = ProjectSuite.Variables.Username;
var password = ProjectSuite.Variables.Password;
Log.Message(username);
Log.Message(password);

// var url = "https://mydirectdeposit.preprodapp.texastech.edu";
// Browsers.Item(BrowserName).Run(url);
//Log.Message("Launch the browser" +BrowserName);

var usernameBox = Aliases.browser.pageEraiderSignIn.SignInForm.Username;
var passwordBox = Aliases.browser.pageEraiderSignIn.SignInForm.Password;

usernameBox.SetText(username);
Log.Message("Entering Username");
passwordBox.SetText(password);
passwordBox.Keys("[Enter]");
Log.Message("Entering Password");
}**/

/**
login to the app using impersonation - https://<url>?debug=true&eraider=
**/

function logCredentialsApplication(){
Log.Message("hello1");
var username = ProjectSuite.Variables.Username;
var password = ProjectSuite.Variables.Password;
Log.Message(username);
Log.Message(password);

//var url = "https://mydirectdeposit.preprodapp.texastech.edu?debug=true&eraider=";
// Browsers.Item(BrowserName).Run(url+argUser);
// Log.Message("Launch the browser" +BrowserName);

var usernameBox = Aliases.browser.pageEraiderSignIn.SignInForm.Username;
var passwordBox = Aliases.browser.pageEraiderSignIn.SignInForm.Password;

usernameBox.SetText(username);
Log.Message("Entering Username");
passwordBox.SetText(password);
passwordBox.Keys("[Enter]");
Log.Message("Entering Password");
}

/***
New changes in eraider
**/
/**
function logCredentials(){
var username = ProjectSuite.Variables.Username;
var password = ProjectSuite.Variables.Password;
Log.Message(username);
Log.Message(password);
var usernameBox = Aliases.browser.AuthenticationDialog.Username;
var passwordBox = Aliases.browser.AuthenticationDialog.Password;

usernameBox.SetText(username);
Log.Message("Entering Username");
passwordBox.SetText(password);
passwordBox.Keys("[Enter]");
Log.Message("Entering Password");

}
**/

function launchBrowser(BrowserName, url)
{
while(Sys.WaitBrowser().Exists)
{
Sys.WaitBrowser().Close();
}
Browsers.Item(BrowserName).Run(url);
Log.Message("Launch the browser" +BrowserName);
Sys.Browser().BrowserWindow(0).Maximize();
}

/**
function logCredentials(browserName,url){
// delay(5000);
// var url = "https://cohortsattributes.preprodapp.texastech.edu"
//Log.Message("Hello1");
var username = ProjectSuite.Variables.Username;
var password = ProjectSuite.Variables.Password;
Browsers.Item(browserName).Run(url)
delay(5000);
// Sys.Browser("*").Page("about:blank");
//Sys.Browser("*").Page("*");

//var page = Sys.Browser("*").Page("about:blank");
// var page = Sys.Browser("*").Page("*");
var page = Sys.Browser().Page("*");
// var page = Sys.Browser().Page("*");
props = ["ObjectType","Name"];
values = ["Login","Login"];

loginObj = page.FindChild(props,values);

if(loginObj.Exists)
{
delay(5000);
Log.Message("Hello");

page.Login.TextBox("UserName").SetText(username);
page.Login.TextBox("Password").SetText(password);
delay(2000);
page.Login.Button("OK").Click();
page.Wait();
Sys.Browser().BrowserWindow(0).Maximize();
}
else{
Log.Error("No/Invalid page");
}

} **/

function logCredentials(browserName,url){
var username = ProjectSuite.Variables.Username;
var password = ProjectSuite.Variables.Password;
Browsers.Item(browserName).Run(url)
delay(5000);
var page = Sys.Browser().Page("*");
try{
// Sys.Browser().BrowserWindow(0).Maximize();
page.Login.TextBox("UserName").SetText(username);
page.Login.Textbox("Password").SetText(password);
delay(2000);
page.Login.Button("OK").Click();
page.Wait();
Sys.Browser().BrowserWindow(0).Maximize();
} catch(e){
Log.Error("Invalid Page/Login" +e);

}
}

 

 

/**
log out of the application - my DirectDeposit application
**/
/**
function logOut()
{
Delay(5000);
var signOutLinkExists = false;
signOutLinkExists = Aliases.browser.pageTtusMyDirectDeposit.linkSignouttext.Exists;
if(signOutLinkExists == true)
{
// var picture = Aliases.browser.pageTtusMyDirectDeposit.Picture();
// Log.Picture(picture, "Sign Out","Sign Out Links");
Log.Message(Aliases.browser.pageTtusMyDirectDeposit.linkSignouttext.contentText);
Aliases.browser.pageTtusMyDirectDeposit.linkSignouttext.Click();

}

}**/

/**
Log out of any application
**/

function LogOut(objLogOutPathName)
{
// Delay(5000);
var objLogOutPathNameExists = false;
try{
objLogOutPathNameExists = objLogOutPathName.Exists;
if(objLogOutPathNameExists == true)
{
Log.Message(objLogOutPathName.contentText);
objLogOutPathName.Click();
}
}catch(e){
Log.Error("Error" +e);
}
}

/**
@function basicAuthentication
@Description - enter the username and password in Basic Authentication dialog
and press the OK button
**/
function basicAuthentication(){
var username = ProjectSuite.Variables.Username;
var password = ProjectSuite.Variables.Password;
var page = Sys.Browser().Page("*");
try{
page.Login.TextBox("UserName").SetText(username);
page.Login.Textbox("password").SetText(password);
delay(2000);
page.Login.Button("OK").Click();
page.Wait();
// Sys.Browser().BrowserWindow(0).Maximize();
} catch(e){
Log.Error("InvalidPage/Login" +e);
}
}

 

module.exports.logCredentials = logCredentials;
module.exports.logCredentialsApplication = logCredentialsApplication;
module.exports.launchBrowser = launchBrowser;
//module.exports.logOut = logOut;
module.exports.LogOut = LogOut;
module.exports.basicAuthentication = basicAuthentication;

tristaanogre
Esteemed Contributor

Where is the distinction between the two units of code?


Robert Martin
[Hall of Fame]
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

@tristaanogre 

I have attached the function code and script code.

 

On the first page is script and on the second page is function 

tristaanogre
Esteemed Contributor

Your complaint talks about the "logCredentials" function... not the browser functions.  I'd still like to see that code, please.

Generally speaking, it sounds like the function is not being exported properly from it's unit. Something is incorrect in your module.exports and requires calls somewhere that you're losing the connection to the function.  So, when you try and call the function, it doesn't recognize the parent object somehow.


Robert Martin
[Hall of Fame]
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
cancel
Showing results for 
Search instead for 
Did you mean: