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;