Currently, I am in the process of developing Automation scripts using Protractor. Within my JavaScript file, which I have named PlatformviewCnOPage, I have created a function called searchCapabilityOfferingsName.
I am facing a challenge where I need to call the searchCapabilityOfferingsName function from within another function in the same JS file. Despite attempting different approaches, such as directly calling the function or creating an object within the same file, I have not been successful. As I am relatively new to JavaScript, I am seeking guidance on how to properly execute this task.
var PlatformviewCnOPage = function() {
this.searchCapabilityOfferingsName = function(){
coreutil.clickElement(objectrepo.platformView_Searchbox_EnterBtn,'xpath');
browser.sleep(2000);
var searchResult= coreutil.getTextofElement(objectrepo.platformView_SearchResult,'xpath');
return searchResult;
}
In my attempt to utilize the searchCapabilityOfferingsName function within another function in the same JS file, I encountered errors stating that the method was not defined. Could anyone provide insights or suggestions to help me overcome this issue?
this.verifySearchinCnO = function(){
this.searchCapabilityOfferingsName(); // Failed-method not defined
searchCapabilityOfferingsName(); // Failed method not defined
Create object of same file and call the function. // Failed.
}
};
module.exports = PlatformviewCnOPage;
If you have any recommendations on how I can successfully call the function within another function in the same JS file, please share your thoughts. Thank you!