/// <summary> /// Login using Valid Email Id & Password /// </summary> /// <param name="column">Column Number to Find Data from the Excel Sheet</param> /// <returns></returns> public Login loginUsingValidEmailIdAndPassword(int column = 0) { #region Datasheet string dataFromSheet = Common.DirectoryPath + ConfigurationManager.AppSettings["DataSheetDir"] + "\\Login.xlsx"; string[] Email = Spreadsheet.GetMultipleValueOfField(dataFromSheet, "Email", "Valid"); string[] Password = Spreadsheet.GetMultipleValueOfField(dataFromSheet, "Password", "Valid"); string email, password = ""; #endregion email = Email[column].ToString(); password = Password[column].ToString(); Assert.IsTrue(driver._isElementPresent("xpath", "//input[@type='email' and @name = 'email']"), "Email Address Textarea not Present."); driver._type("xpath", "//input[@type='email' and @name = 'email']", email); Results.WriteStatus(test, "Pass", "Information Inputed successfully.<b> Email Address : " + email); clickButtonOnLoginPage("Next"); VerifyPasswordScreenOnLoginPage(); driver._type("id", "password", password); Results.WriteStatus(test, "Pass", "Information Inputed successfully.<b> Password : "******"Sign in"); return(new Login(driver, test)); }
/// <summary> /// Enter First or Last Name on Edit Profile Form /// </summary> /// <param name="firstName">where to enter value</param> /// <returns></returns> public String enterFirstOrLastNameOnEditProfileForm(bool blankValue, bool firstName) { driver._selectFrameFromDefaultContent("xpath", "//div[contains(@class,'brand-item-container')]/iframe"); string fieldValue = ""; if (firstName) { Assert.AreEqual(true, driver._isElementPresent("xpath", "//input[@id='firstName']"), "'First Name' Text area not present."); if (blankValue == false) { fieldValue = driver._getValue("xpath", "//input[@id='firstName']") + driver._randomString(3, true); } driver._type("xpath", "//input[@id='firstName']", fieldValue); Results.WriteStatus(test, "Pass", "Entered, '" + fieldValue + "' Value for 'First Name' Field."); } else { Assert.AreEqual(true, driver._isElementPresent("xpath", "//input[@id='lastName']"), "'Last Name' Text area not present."); if (blankValue == false) { fieldValue = driver._getValue("xpath", "//input[@id='lastName']") + driver._randomString(3, true); } driver._type("xpath", "//input[@id='lastName']", fieldValue); Results.WriteStatus(test, "Pass", "Entered, '" + fieldValue + "' Value for 'Last Name' Field."); } Thread.Sleep(1000); driver._selectFrameToDefaultContent(); return(fieldValue); }
/// <summary> /// Verify File Downloaded Or Not for Chart /// </summary> /// <param name="fileName">File Name to Verify</param> /// <param name="FileType">File Extension to Verify</param> /// <returns></returns> public string VerifyFileDownloadedOrNotOnScreen(string fileName, string FileType) { bool Exist = false; string FilePath = ""; string Path = ExtentManager.ResultsDir; string[] filePaths = Directory.GetFiles(Path, FileType); foreach (string filePath in filePaths) { FileInfo ThisFile = new FileInfo(filePath); if (filePath.Contains(fileName + "-" + DateTime.Today.ToString("yyyyMMdd")) || filePath.Contains(fileName)) { ThisFile = new FileInfo(filePath); FilePath = filePath; if (ThisFile.LastWriteTime.ToShortTimeString() == DateTime.Now.ToShortTimeString() || ThisFile.LastWriteTime.AddMinutes(1).ToShortTimeString() == DateTime.Now.ToShortTimeString() || ThisFile.LastWriteTime.AddMinutes(2).ToShortTimeString() == DateTime.Now.ToShortTimeString() || ThisFile.LastWriteTime.AddMinutes(3).ToShortTimeString() == DateTime.Now.ToShortTimeString() || ThisFile.LastWriteTime.AddMinutes(4).ToShortTimeString() == DateTime.Now.ToShortTimeString()) { Exist = true; break; } } } Assert.AreEqual(true, Exist, "'" + fileName + "' " + FileType.Replace("*", "").ToUpper() + "' File Not Exported Properly."); Results.WriteStatus(test, "Pass", "Verified, <b>'" + FileType.Replace("*", "").ToUpper() + "'</b> File Exported Properly for '" + fileName + "' Report File."); return(FilePath); }
/// <summary> /// Click Numerator logo from bottom /// </summary> /// <returns></returns> public Home clickMarketTrackLogoFromBottom() { Assert.AreEqual(true, driver._isElementPresent("xpath", "//div[@ng-if='footerCtrl.data.company.isVisible']/a"), "'Numerator' Logo not present at bottom."); driver._clickByJavaScriptExecutor("//div[@ng-if='footerCtrl.data.company.isVisible']/a"); Results.WriteStatus(test, "Pass", "Clicked, Numerator Logo from Bottom."); return(new Home(driver, test)); }
/// <summary> /// To Verify Home Page /// </summary> /// <returns></returns> public Home verifyHomePage() { Assert.IsTrue(driver._waitForElement("xpath", "//img[@alt='Product Logo']", 20), "Home Page Logo not Present."); Thread.Sleep(5000); if (driver._isElementPresent("xpath", "//span[@class='lead' and contains(text(),'Almost there')]")) { driver._waitForElementToBeHidden("xpath", "//span[@class='lead' and contains(text(),'Almost there')]"); } Assert.IsTrue(driver._waitForElement("xpath", "//*[@id='domain-carousel']/ol", 20), "Carousel not Present on Screen."); driver._waitForElementToBeHidden("xpath", "//p[@class='lead' and contains(text(),'Loading')]"); int cnt = 0; IList <IWebElement> loadingCount = driver.FindElements(By.XPath("//p[@class='lead' and contains(text(),'Loading')]")); do { Thread.Sleep(1000); loadingCount = driver.FindElements(By.XPath("//p[@class='lead' and contains(text(),'Loading')]")); cnt++; if (cnt == 15) { break; } } while (loadingCount.Count.Equals(0) == false); driver._waitForElementToBeHidden("xpath", "//p[@class='lead' and contains(text(),'Loading')]"); Assert.AreEqual(0, loadingCount.Count, "Home Page Not Load Properly."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[@class='btn btn-default active']"), "Dashboard Page not Display Properly."); Results.WriteStatus(test, "Pass", "Verified, Home Page Screen."); verifyRecordsOnReportScreen(); return(new Home(driver, test)); }
/// <summary> /// Click Schedule Dropdown and Verify Lists /// </summary> /// <returns></returns> public Schedule clickScheduleDropdownAndVerifyListsOrClick(string scheduleOption = "") { driver._clickByJavaScriptExecutor("//div[@class='btn-group']/button[@class='btn btn-default dropdown-toggle']"); IList <IWebElement> lists = driver.FindElements(By.XPath("//div[@class='btn-group open']/ul/li/a")); string[] listNames = { "Daily", "Weekly", "Monthly" }; for (int i = 0; i < listNames.Length; i++) { if (scheduleOption != "") { if (scheduleOption.Equals(lists[i].Text)) { lists[i].Click(); Thread.Sleep(500); break; } } else { Assert.AreEqual(lists[i].Text, listNames[i], "'" + lists[i].Text + "' Option not Present on Schedule Dropdown."); } } Results.WriteStatus(test, "Pass", "Clicked, Schedule Dropdown and Verified Lists."); return(new Schedule(driver, test)); }
/// <summary> /// verify Schedule Message on Screen /// </summary> /// <param name="message">message</param> /// <returns></returns> public Schedule verifyScheduleMessageOnScreen(string message) { Assert.AreEqual(true, driver._isElementPresent("xpath", "//cft-scheduled-export-popover-form//.//span"), "Successfully created a scheduled export for Message not Present."); Assert.AreEqual(true, driver._getText("xpath", "//cft-scheduled-export-popover-form//.//span").Contains(message), "'" + message + "' message not match."); Results.WriteStatus(test, "Pass", "Verified, '" + message + "' Message on Screen."); return(new Schedule(driver, test)); }
/// <summary> /// Select Second Reset password mail to open Reset link /// </summary> /// <param name="mailContent">Mail Content to Verify and open mail</param> /// <returns></returns> public Login selectSecondResetPasswordMailToOpenResetLink(bool mailContent = false) { Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[@class='lvHighlightAllClass lvHighlightSubjectClass']"), "Mails Subject not Present."); IList <IWebElement> mailSubjects = driver._findElements("xpath", "//span[@class='lvHighlightAllClass lvHighlightSubjectClass']"); bool avail = false; for (int m = 0; m < mailSubjects.Count; m++) { if (mailSubjects[m].Text.Contains("Your password reset instructions from Numerator")) { for (int j = m + 1; j < mailSubjects.Count; j++) { if (mailSubjects[j].Text.Contains("Your password reset instructions from Numerator")) { mailSubjects[j].Click(); Thread.Sleep(2000); avail = true; break; } } } if (avail) { break; } } Assert.AreEqual(true, avail, "'Your FeatureVision(R) Password Reset Request' Mail not Present."); Results.WriteStatus(test, "Pass", "Selected, Reset Password Email."); Assert.IsTrue(driver._waitForElement("xpath", "//div[@aria-label='Message Contents']", 20), "Message Content not Present."); IWebElement body = driver._findElement("xpath", "//div[@aria-label='Message Contents']"); if (mailContent) { Assert.AreEqual(true, body.Text.Contains("We got a request to reset your Numerator password. This link is only valid for 36 hours."), "'We got a request to reset your Numerator password. This link is only valid for 36 hours.' Message not Present or match."); Assert.AreEqual(true, body.Text.Contains("If you ignore this message, your password won't be changed."), "'If you ignore this message, your password won't be changed.' Message not Present or match."); Assert.AreEqual(true, body.Text.Contains("If you didn't request a password reset, please visit our help center at help.markettrack.com."), "'If you didn't request a password reset, please visit our help center at help.markettrack.com.' Message not Present or match."); Assert.AreEqual(true, body.Text.Trim().Replace("\r\n", "").Contains("Thanks,The Numerator Team"), "'Thanks, The Numerator Team' Message not Present or match."); Results.WriteStatus(test, "Pass", "Verified, Mail Contents."); } IList <IWebElement> content = body.FindElements(By.TagName("a")); bool resetLink = false; for (int i = 0; i < content.Count(); i++) { if (content[i].Text.Contains("Reset your password")) { content[i].Click(); resetLink = true; Thread.Sleep(5000); break; } } Assert.AreEqual(true, resetLink, "'Reset Password' Link not Present on Content."); Results.WriteStatus(test, "Pass", "Clicked, Reset Password Link from Email."); return(new Login(driver, test)); }
///<summary> ///Click On Button of View Ad Popup ///</summary> ///<param name="button">Button to be clicked</param> ///<returns></returns> public ViewAdPopup clickOnButtonOfViewAdPopup(string button) { Assert.IsTrue(driver._isElementPresent("xpath", "//cft-domain-item-modal-footer//button[text()=' Download Asset ']"), "'Download Asset' button not present on Creative Details Popup"); Assert.IsTrue(driver._isElementPresent("xpath", "//cft-domain-item-modal-footer//button[text()='Close']"), "'Close' button not present on Creative Details Popup"); if (button.ToLower().Equals("download asset")) { driver._click("xpath", "//cft-domain-item-modal-footer//button[text()=' Download Asset ']"); } else if (button.ToLower().Equals("close")) { driver._click("xpath", "//cft-domain-item-modal-footer//button[text()='Close']"); } if (button.ToLower().Equals("download grid")) { driver._click("xpath", "//div[@class='modal-body pb-0']//button[@class='btn btn-link'][1]"); } if (button.ToLower().Equals("grid options")) { driver._click("xpath", "//button//span[@class='pl-1' and text()='Grid Options']"); } if (button.ToLower().Equals("image")) { driver._click("xpath", "//div[@class='modal-body pb-0']//img"); } Results.WriteStatus(test, "Pass", "Clicked, '" + button + "' on View Ad Popup"); return(new ViewAdPopup(driver, test)); }
/// <summary> /// Verify Password Updated Label and Click Login Link /// </summary> /// <returns></returns> public Login enterPasswordAndClickButton(string buttonName, string passwordType) { string dataFromSheet = Common.DirectoryPath + ConfigurationManager.AppSettings["DataSheetDir"] + "\\Login.xlsx"; string[] Password = Spreadsheet.GetMultipleValueOfField(dataFromSheet, "Password", "Valid"); string newPassword = ""; string confirmPassword = ""; if (passwordType == "Invalid") { newPassword = "******"; confirmPassword = "******"; } else if (passwordType == "New Same Password") { newPassword = "******"; confirmPassword = "******"; } else if (passwordType == "Lower Case") { newPassword = "******"; confirmPassword = "******"; } else { newPassword = Password[0].ToString(); confirmPassword = Password[0].ToString(); } driver._type("id", "password", newPassword); Thread.Sleep(1000); driver._type("id", "password_confirmation", confirmPassword); Thread.Sleep(1000); driver._clickByJavaScriptExecutor("//span[@class='btn-left-side' and text() = '" + buttonName + "']"); Thread.Sleep(5000); Results.WriteStatus(test, "Pass", "Entered, Password & Confirm Password and Clicked " + buttonName + " Button."); return(new Login(driver, test)); }
/// <summary> /// Verify Outlook Home Page /// </summary> /// <returns></returns> public Login VerifyOutlookHomePage() { Assert.IsTrue(driver._waitForElement("xpath", "//span[@title='Inbox' and text() = 'Inbox']", 20), "Inbox Folder not Present."); Assert.IsTrue(driver._waitForElement("xpath", "//div[@role='option' and @aria-haspopup='true']", 20), "Emails List not Present."); Results.WriteStatus(test, "Pass", "Verified, Outlook Home Page."); return(new Login(driver, test)); }
/// <summary> /// Verify Create New Password or Successfull Password Screen /// </summary> /// <param name="emailAddress">Email Address</param> /// <param name="successfullMessage">Verify Successfull Message Screen</param> /// <returns></returns> public Login VerifyCreateANewPasswordOrSuccessfullPasswordScreen(string emailAddress, bool successfullMessage = false) { Assert.IsTrue(driver._isElementPresent("xpath", "//img[@class='CFT-login-logo']"), "Numerator Logo not Present on Reset Password Screen."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//p[@class='text-center']"), "Instructions Not Present on Reset Password Screen."); if (successfullMessage) { Assert.AreEqual(true, driver._getText("xpath", "//p[@class='text-center']").Contains("You successfully entered your current password for " + emailAddress + "."), "'You successfully entered your current password for' Message Not match on Screen."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[@class='btn-left-side' and text() = 'Continue to site']"), "'Continue to site' Button not Present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[@class='btn-left-side' and text() = 'Back to set new password']"), "'Back to set new password' Button not Present."); Results.WriteStatus(test, "Pass", "Verified, Successfull Entered Password Screen on Page."); } else { Assert.AreEqual(true, driver._getText("xpath", "//p[@class='text-center']").Contains("Create a new password for " + emailAddress + "."), "'Create a new password for' Message Not match on Reset Password Screen."); Assert.AreEqual(true, driver._isElementPresent("id", "password"), "New Password textarea not Present."); Assert.AreEqual(true, driver._isElementPresent("id", "password_confirmation"), "Confirm Password textarea not Present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//label[@class='field-checkbox show-password']"), "Show Password Checkbox not Present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[@class='btn-left-side' and text() = 'Set password']"), "'Set password' Button not Present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[@class='btn-left-side' and text() = 'Back to sign in']"), "'Back to sign in' Button not Present."); Results.WriteStatus(test, "Pass", "Verified, Create a new password Screen."); } return(new Login(driver, test)); }
/// <summary> /// Click Button on Reset Password screen /// </summary> /// <param name="buttonName">Button Name to Click</param> /// <returns></returns> public Login clickButtonOnResetPasswordScreen(string buttonName) { Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[@class='btn-left-side' and text() = '" + buttonName + "']"), "'" + buttonName + "' Button not Present."); driver._clickByJavaScriptExecutor("//span[@class='btn-left-side' and text() = '" + buttonName + "']"); Results.WriteStatus(test, "Pass", "Clicked, '" + buttonName + "' Button on Reset Password Screen."); return(new Login(driver, test)); }
/// <summary> /// Check Show Password Checkbox on Password Screen /// </summary> /// <param name="unChecked">unChecked Show password Checkbox</param> /// <returns></returns> public Login checkShowPasswordCheckboxOnPasswordScreen(bool unChecked = false) { if (unChecked) { if (driver._getAttributeValue("id", "password", "type").Equals("text")) { driver._clickByJavaScriptExecutor("//label[@class='field-checkbox show-password']/span"); } Assert.AreEqual("password", driver._getAttributeValue("id", "password", "type"), "'Show password' Checkbox not UnChecked."); Results.WriteStatus(test, "Pass", "UnChecked 'Show password' Checkbox on Password Screen."); } else { if (driver._getAttributeValue("id", "password", "type").Equals("password")) { driver._clickByJavaScriptExecutor("//label[@class='field-checkbox show-password']/span"); } Assert.AreEqual("text", driver._getAttributeValue("id", "password", "type"), "'Show password' Checkbox not Checked."); Results.WriteStatus(test, "Pass", "Checked 'Show password' Checkbox on Password Screen."); } return(new Login(driver, test)); }
/// <summary> /// Verify Thumbnail Section on Screen /// </summary> /// <returns></returns> public Schedule verifyThumbnailSectionOnScreen() { Assert.AreEqual(true, driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']"), "Ad Thumbnail not Present for Table View Screen."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']//.//img"), "Ad Image not Present on Section."); IWebElement image = driver._findElement("xpath", "//div[@class='aditem aditem-long']//.//img"); bool loaded = Convert.ToBoolean(((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].complete && typeof arguments[0].naturalWidth != 'undefined' && arguments[0].naturalWidth > 0", image)); Assert.AreEqual(true, loaded, "'(" + image.GetAttribute("src") + ")' Image Not Load on Thumbnail Section."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']//.//div[@class='detail-view-content']"), "Detail View section not Present on Ad Image Section."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']//.//button[contains(text(),'View Ad')]"), "View Ad Icon not Present on Ad Image."); if (driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']//.//button[contains(text(),'Markets')]")) { Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']//.//button[contains(text(),'Markets')]"), "Markets Icon not Present on Ad Image."); } else { Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']//.//button[contains(text(),'Occurrences')]"), "Occurrences Icon not Present on Ad Image."); } Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='aditem aditem-long']//.//button[contains(text(),'Details')]"), "Details Icon not Present on Ad Image."); Results.WriteStatus(test, "Pass", "Verified, Thumbnail Section on Screen."); return(new Schedule(driver, test)); }
///<summary> ///Search For Saved Search Name ///</summary> ///<returns></returns> public ScheduledAlertManager SearchForSavedSearchName(string savedSearchName, bool present = true) { Assert.IsTrue(driver._isElementPresent("xpath", "//tr/td[1]"), "Action icon not present."); IList <IWebElement> savedSearchesColl = driver._findElements("xpath", "//tr/td[1]"); bool avail = false; foreach (IWebElement savedSearch in savedSearchesColl) { ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", savedSearch); if (savedSearch.Text.ToLower().Equals(savedSearchName.ToLower())) { avail = true; break; } } if (present) { Assert.IsTrue(avail, "'" + savedSearchName + "' option not present."); Results.WriteStatus(test, "Pass", "'" + savedSearchName + "' option is present."); } else { Assert.IsFalse(avail, "'" + savedSearchName + "' option is present."); Results.WriteStatus(test, "Pass", "'" + savedSearchName + "' option is not present."); } Results.WriteStatus(test, "Pass", "Searched, For Saved Search Name '" + savedSearchName + "'"); return(new ScheduledAlertManager(driver, test)); }
/// <summary> /// Verify Tooltip message on filter section /// </summary> /// <param name="message">Tooltip Message to Verify</param> /// <returns></returns> public Schedule verifyTooltipMessageOrClickButtonOnScreen(string buttonName, string message, bool clickButton = false) { driver._waitForElementToBeHidden("xpath", "//span[@class='lead' and contains(text(),'Loading Pivot Data')]"); Thread.Sleep(2000); IList <IWebElement> buttons = driver.FindElements(By.XPath("//div[@class='btn-group btn-grid-actions']//.//button")); for (int i = 0; i < buttons.Count; i++) { if (buttons[i].Text.Contains(buttonName) == true) { driver.MouseHoverByJavaScript(buttons[i]); if (clickButton) { buttons[i].Click(); Results.WriteStatus(test, "Pass", "Clicked on '" + buttonName + "' Button on Screen."); } break; } } if (clickButton == false) { Assert.AreEqual(true, driver._isElementPresent("xpath", "//div[@class='tooltip-inner']"), "Tooltip not Present on Screen."); Assert.AreEqual(message, driver._getText("xpath", "//div[@class='tooltip-inner']"), "'" + message + "' Tooltip message not match."); Results.WriteStatus(test, "Pass", "Verified, '" + message + "' Tooltip message for '" + buttonName + "' Button on Screen."); } return(new Schedule(driver, test)); }
/// <summary> /// Move Items From Visible To Hidden /// </summary> /// <param name="num">Number of Items to be added</param> /// <returns></returns> public string[] moveItemsFromVisibleToHidden(int num = 1) { string[] movedItems = new string[num]; Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div/button"), "Remove button not present."); IList <IWebElement> removeButtonCollection = driver._findElements("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div/button"); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div/div[text()]"), "Visible Items' names not present"); IList <IWebElement> visibleItemNamesCollections = driver._findElements("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div/div[text()]"); Random rand = new Random(); int x = rand.Next(0, removeButtonCollection.Count); for (int i = 0; i < num; i++) { removeButtonCollection = driver._findElements("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div/button"); visibleItemNamesCollections = driver._findElements("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div/div[text()]"); x = rand.Next(x, removeButtonCollection.Count); movedItems[i] = visibleItemNamesCollections[x].Text; removeButtonCollection[x].Click(); Thread.Sleep(1000); } Results.WriteStatus(test, "Pass", "Moved, " + num + " visible items to hidden items."); return(movedItems); }
/// <summary> /// Click Button on Screen /// </summary> /// <param name="buttonName">Button Name to Click</param> /// <returns></returns> public Schedule clickButtonOnScreen(string buttonName) { if (buttonName.Equals("Create Scheduled Export")) { Assert.IsTrue(driver._waitForElement("xpath", "//button[@class='btn btn-default' and contains(text(),'Create Scheduled Export')]", 20), "'Create Scheduled Export' Button not Present."); driver._clickByJavaScriptExecutor("//button[@class='btn btn-default' and contains(text(),'Create Scheduled Export')]"); } if (buttonName.Equals("Save As")) { Assert.IsTrue(driver._waitForElement("xpath", "//button[@class='btn btn-default' and contains(text(),'Save As')]", 20), "'Save As...' Button not Present."); driver._clickByJavaScriptExecutor("//button[@class='btn btn-default' and contains(text(),'Save As')]"); } if (buttonName.Equals("Save!")) { Assert.IsTrue(driver._waitForElement("xpath", "//button[@class='btn btn-success' and contains(text(),'Save!')]", 20), "'Save!' Button not Present."); driver._clickByJavaScriptExecutor("//button[@class='btn btn-success' and contains(text(),'Save!')]"); } if (buttonName.Equals("Apply Search")) { Assert.IsTrue(driver._waitForElement("xpath", "//button[@class='btn btn-primary' and contains(text(),'Apply Search')]", 20), "'Apply Search' Button not Present."); driver._clickByJavaScriptExecutor("//button[@class='btn btn-primary' and contains(text(),'Apply Search')]"); } Thread.Sleep(2000); Results.WriteStatus(test, "Pass", "Clicked, '" + buttonName + "' Button on screen."); return(new Schedule(driver, test)); }
/// <summary> /// Click Button on Field Options Popup /// </summary> /// <param name="button">Button to be clicked</param> /// <returns></returns> public FieldOptions clickButtonOnFieldOptionsPopup(string button) { string buttonXPath = ""; switch (button.ToLower()) { case "cancel": buttonXPath = "//div[@class='modal-footer pt-0']//button[text()='Cancel ']"; driver._waitForElementToBeHidden("xpath", "//div[@class='modal-content']"); break; case "reset": buttonXPath = "//div[@class='modal-footer pt-0']//button[text()='Reset ']"; break; case "apply": buttonXPath = "//div[@class='modal-footer pt-0']//button[text()='Apply ']"; driver._waitForElementToBeHidden("xpath", "//div[@class='modal-content']"); break; default: break; } driver._click("xpath", buttonXPath); Thread.Sleep(2000); Results.WriteStatus(test, "Pass", "Clicked, '" + button + "' button on Field Options Popup."); return(new FieldOptions(driver, test)); }
/// <summary> /// Click User Menu and Select Account from List /// </summary> /// <param name="accountName">Account Name to select</param> /// <returns></returns> public Home clickUserMenuAndSelectAccountFromList(string accountName) { Assert.AreEqual(true, driver._isElementPresent("xpath", "//div[contains(@class,'btn-group ng-scope dropdown btn-group-info')]"), "User Menu not Present on screen."); if (driver._isElementPresent("xpath", "//div[@class='btn-group ng-scope dropdown btn-group-info open']") == false) { driver._clickByJavaScriptExecutor("//div[@class='btn-group ng-scope dropdown btn-group-info']/button"); Assert.IsTrue(driver._waitForElement("xpath", "//div[@class='btn-group ng-scope dropdown btn-group-info open']", 10), "User Menu Icon List not Open."); } bool avail = false; IList <IWebElement> accounts = driver.FindElements(By.XPath("//ul[contains(@class,'dropdown-menu dropdown-menu-form dropdown-menu-scroll')]/li")); for (int i = 0; i < accounts.Count; i++) { if (accounts[i].Text.Contains(accountName)) { accounts[i].Click(); Thread.Sleep(5000); avail = true; break; } } Assert.AreEqual(true, avail, "'" + accountName + "' Account not Present on List."); Results.WriteStatus(test, "Pass", "Clicked, User Menu and Selected '" + accountName + "' Account name from List."); return(new Home(driver, test)); }
/// <summary> /// Get Items From Field in Field Options Popup /// </summary> /// <param name="field">Hidden or Visible</param> /// <returns></returns> public string[] getItemsFromFieldInFieldOptionsPopup(string field) { string fieldXpath = ""; if (field.ToLower().Equals("hidden")) { fieldXpath = "//div[@class='modal-body pt-3']//div[@class='col pl-1']//div[not(@class)]/div/div[text()]"; } else { fieldXpath = "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div/div[text()]"; } Assert.IsTrue(driver._isElementPresent("xpath", fieldXpath), "'" + field + "' items not present"); IList <IWebElement> fieldItemsCollection = driver._findElements("xpath", fieldXpath); string[] itemsList = new string[fieldItemsCollection.Count]; for (int i = 0; i < itemsList.Length; i++) { itemsList[i] = fieldItemsCollection[i].Text.ToLower(); } Results.WriteStatus(test, "Pass", "Captured, Items From '" + field + "' Field in Field Options Popup"); return(itemsList); }
/// <summary> /// Click on day Filter Field and Click on Option /// </summary> /// <param name="optionName">Option Name for Click</param> /// <returns></returns> public Home clickOnDayFilterFieldAndClickOption(string optionName = "") { Assert.AreEqual(true, driver._isElementPresent("xpath", "//nav[@class='navbar' and @role='navigation']/ul/li"), "Filter Options not Present."); IList <IWebElement> fieldsCollection = driver.FindElements(By.XPath("//nav[@class='navbar' and @role='navigation']/ul/li")); Assert.AreEqual(true, driver._isElementPresent("xpath", "//*[contains(@id,'internal_timeframe')]/a")); driver._clickByJavaScriptExecutor("//*[contains(@id,'internal_timeframe')]/a"); Thread.Sleep(500); IList <IWebElement> optionsCollections = driver.FindElements(By.XPath("//li[@class='dropdown open']//.//ul/li[1]//.//ul[contains(@class,'insert-ranges')]/li")); if (optionName != "") { for (int j = 0; j < optionsCollections.Count; j++) { if (optionName == optionsCollections[j].Text) { optionsCollections[j].Click(); Thread.Sleep(5000); driver._waitForElement("xpath", "//*[@id='domain-carousel']/ol", 20); break; } } } Results.WriteStatus(test, "Pass", "Clicked, Days Filter field and Clicked '" + optionName + "' option"); return(new Home(driver, test)); }
/// <summary> /// Verify Field Options Popup /// </summary> /// <returns></returns> public FieldOptions VerifyFieldOptions(bool popupVisible = true) { if (popupVisible) { driver._click("xpath", "//button[@tooltip='Field Options']"); Assert.IsTrue(driver._waitForElement("xpath", "//div[@class='modal-content']"), "Field Options popup not present"); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-content']//h4"), "Field options popup header is not present."); Assert.AreEqual("Customize Your Visible Fields...", driver._getText("xpath", "//div[@class='modal-content']//h4"), "Field Options popup header text does not match."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']/div"), "' Visible Fields ' section in Field options popup is not present."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[contains(@class, 'text')]"), "' Visible Fields ' section header in Field options popup is not present."); Assert.AreEqual("Visible Fields", driver._getText("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[contains(@class, 'text')]"), "' Visible Fields ' section header text does not match."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pr-1']//div[not(@class)]/div"), "' Visible Fields ' section items in Field options popup is not present."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pl-1']/div"), "' Hidden Fields ' section in Field options popup is not present."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pl-1']//div[contains(@class, 'text')]"), "' Hidden Fields ' section header in Field options popup is not present."); Assert.AreEqual("Hidden Fields", driver._getText("xpath", "//div[@class='modal-body pt-3']//div[@class='col pl-1']//div[contains(@class, 'text')]"), "' Hidden Fields ' section header text does not match."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-body pt-3']//div[@class='col pl-1']//div[not(@class)]/div"), "' Hidden Fields ' section items in Field options popup is not present."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-footer pt-0']//button[text()='Cancel ']"), "'Cancel' button is not present."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-footer pt-0']//button[text()='Apply ']"), "'Apply' button is not present."); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='modal-footer pt-0']//button[text()='Reset ']"), "'Reset' button is not present."); Results.WriteStatus(test, "Pass", "Verified, Field Options Popup."); } else { Assert.IsTrue(driver._waitForElementToBeHidden("xpath", "//div[@class='modal-content']"), "Field Options popup not closed"); Results.WriteStatus(test, "Pass", "Verified, Field Options Popup is closed."); } return(new FieldOptions(driver, test)); }
/// <summary> /// Verify Edit Profile Section on screen /// </summary> /// <returns></returns> public UserProfile VerifyEditProfileSectionOnScreen() { driver._selectFrameFromDefaultContent("xpath", "//div[contains(@class,'brand-item-container')]/iframe"); Assert.IsTrue(driver._waitForElement("xpath", "//div[@class='CFT-auth-header']", 20), "Image Logo Header not present."); Assert.AreEqual(true, driver._waitForElement("xpath", "//img[@class='CFT-login-logo']", 20), "Image Logo not present."); Assert.IsTrue(driver._waitForElement("xpath", "//form[@class='edit-profile track-dirty-state']", 20), "Edit Profile Form not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//label[@for='firstName' and text()='First name']"), "'First Name' Label not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//input[@name='firstName']"), "'First Name' Text area not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//label[@for='lastName' and text()='Last name']"), "'Last name' Label not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//input[@name='lastName']"), "'Last Name' Text area not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//label[@for='country' and text()='Country']"), "'Country' Label not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[contains(@id,'country-container')]"), "'Country' List not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//label[@for='language' and text()='Language']"), "'Language' Label not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[contains(@id,'language-container')]"), "'Language' List not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//label[@for='timezone' and text()='Timezone']"), "'Timezone' Label not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//span[contains(@id,'timezone-container')]"), "'Timezone' List not present."); Assert.AreEqual(true, driver._isElementPresent("id", "update-profile"), "Update Profile Button not present."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//a[contains(@class,'btn btn-warning btn-block')]"), "Change Password Button not present."); driver._selectFrameToDefaultContent(); Assert.AreEqual(true, driver._isElementPresent("xpath", "//div[@class='cfp-hotkeys-close']"), "Close Icon not present."); Results.WriteStatus(test, "Pass", "Verified, Edit Profile Section on screen."); return(new UserProfile(driver, test)); }
///<summary> ///Verify Field Options And Export Icons ///</summary> ///<returns></returns> public FieldOptions VerifyFieldOptionsAndExportIcons(bool fieldOptionPresent, bool exportPresent) { if (fieldOptionPresent) { Assert.IsTrue(driver._isElementPresent("xpath", "//button[@tooltip='Field Options']"), "Field Options Button not present"); Results.WriteStatus(test, "Pass", "Field Options Icon is present"); } else { Assert.IsFalse(driver._isElementPresent("xpath", "//button[@tooltip='Field Options']"), "Field Options Button is present"); Results.WriteStatus(test, "Pass", "Field Options Icon not is present"); } if (exportPresent) { Assert.IsTrue(driver._isElementPresent("xpath", "//button[@tooltip='Export Results']"), "Export Button not present"); Results.WriteStatus(test, "Pass", "Export Icon is present"); } else { Assert.IsFalse(driver._isElementPresent("xpath", "//button[@tooltip='Field Options']"), "Export Button is present"); Results.WriteStatus(test, "Pass", "Export Icon not is present"); } return(new FieldOptions(driver, test)); }
///<summary> ///Select Account Name on User Screen ///</summary> ///<param name="accountName">Account Name to be selected</param> ///<returns></returns> public UserProfile selectAccountNameOnUserScreen(string accountName) { Assert.IsTrue(driver._waitForElement("xpath", "//cft-user-page//h1"), "User Info Screen not present"); Assert.IsTrue(driver._isElementPresent("xpath", "//div[@class='d-flex']//div[text()='ACCOUNT:']"), "Account Label not present on User Screen"); Assert.IsTrue(driver._isElementPresent("xpath", "//cft-account-switcher//div[@class='dropdown']/a"), "Switch Account Button not present on User Screen"); driver._click("xpath", "//cft-account-switcher//div[@class='dropdown']/a"); Assert.IsTrue(driver._waitForElement("xpath", "//cft-account-switcher//div[@class='NU-scrolling-area']/a"), "Account DDL not present"); IList <IWebElement> accountDDLCollection = driver._findElements("xpath", "//cft-account-switcher//div[@class='NU-scrolling-area']/a"); bool avail = false; foreach (IWebElement account in accountDDLCollection) { if (account.Text.ToLower().Contains(accountName.ToLower())) { avail = true; account.Click(); break; } } Assert.IsTrue(avail, "'" + accountName + "' not found"); Thread.Sleep(1000); Results.WriteStatus(test, "Pass", "Selected, Account '" + accountName + "' on User Screen"); return(new UserProfile(driver, test)); }
///<summary> ///Click On Secondary Button ///</summary> ///<param name="button">Button to be clicked</param> ///<returns></returns> public SecondaryButtons clickOnSecondaryButtons(string button) { if (button.ToLower().Contains("schedule") || button.ToLower().Contains("alert")) { driver._click("xpath", "//cft-saved-search-dropdown//cft-scheduled-export-modal//button"); } else if (button.ToLower().Contains("delete")) { driver._click("xpath", "//cft-saved-search-dropdown//button[@tooltip='Delete this search']"); } else if (button.ToLower().Contains("default")) { driver._click("xpath", "//cft-saved-search-dropdown//button[@tooltip='Make this my default search']"); } else if (button.ToLower().Contains("save")) { driver._click("xpath", "//cft-saved-search-save-modal//button"); } else if (button.ToLower().Contains("reset")) { driver._click("xpath", "//cft-saved-search-dropdown//button[@tooltip='Reset this search']"); } else { Results.WriteStatus(test, "Info", "No Secondary Button was clicked"); } Thread.Sleep(4000); Results.WriteStatus(test, "Pass", "Clicked, '" + button + "' button from Secondary Buttons"); return(new SecondaryButtons(driver, test)); }
/// <summary> /// Click Icon Button on screen for chart /// </summary> /// <param name="chartName">Chart Name to Verify</param> /// <param name="iconName">Icon Name to click</param> /// <returns></returns> public BrandDashboard clickIconButtonOnScreenForChart(string chartName, string iconName) { string divName = "chart-creative-advertiserMediaMix"; if (chartName.Equals("Count of Creatives Running by Competitor")) { divName = "chart-creative-shareOfVoice"; } if (chartName.Equals("Full Screen")) { divName = "selected-chart"; } bool avail = false; if (iconName.Equals("Schedule")) { Assert.AreEqual(null, driver.FindElement(By.XPath("//chart-export[contains(@target,'" + divName + "')]//.//div[@class='export-button']/cft-scheduled-export-popover//.//button[contains(@class,'nested-btn')]")).GetAttribute("disabled"), "Schedule Icon button is Disable."); driver._clickByJavaScriptExecutor("//chart-export[contains(@target,'" + divName + "')]//.//div[@class='export-button']/cft-scheduled-export-popover//.//i"); avail = true; } else { Assert.AreEqual(true, driver._isElementPresent("xpath", "//chart-export[contains(@target,'" + divName + "')]//.//div[@class='export-button']/button[@uib-tooltip='" + iconName + "']"), "'" + iconName + "' Icon not present for Chart."); driver._clickByJavaScriptExecutor("//chart-export[contains(@target,'" + divName + "')]//.//div[@class='export-button']/button[@uib-tooltip='" + iconName + "']"); avail = true; } Thread.Sleep(3000); Assert.AreEqual(true, avail, "'" + iconName + "' Icon not present for Chart."); Results.WriteStatus(test, "Pass", "Clicked, '" + iconName + "' Button Icon on screen for '" + chartName + "' Chart."); return(new BrandDashboard(driver, test)); }
/// <summary> /// Verify Password Screen on Login Page /// </summary> /// <returns></returns> public Login VerifyPasswordScreenOnLoginPage(bool EmailId = false) { #region Datasheet string dataFromSheet = Common.DirectoryPath + ConfigurationManager.AppSettings["DataSheetDir"] + "\\Login.xlsx"; string[] Email = Spreadsheet.GetMultipleValueOfField(dataFromSheet, "Email", "Valid"); #endregion Assert.IsTrue(driver._waitForElement("xpath", "//p[contains(text(),'Enter the password for')]", 20), "'Enter the password for' Label not present."); if (EmailId) { Assert.AreEqual(true, driver._isElementPresent("xpath", "//b[text() = '" + Email[0].ToString() + "']"), "Entered Email not match."); } Assert.AreEqual(true, driver._isElementPresent("id", "password"), "Email input area not found on Page."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//input[@id='password' and @placeholder='Please enter your password']"), "'Please enter your password' Placeholder not found on match."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//label[@class='field-checkbox show-password']/span"), "Show Password Checkbox not found on Page."); Assert.AreEqual("Show password", driver._getText("xpath", "//label[@class='field-checkbox show-password']/span"), "Show Password Checkbox label not match."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//button[@class='CFT-auth-btn btn btn-primary btn-block']/span"), "Sigin in Button not found on Page."); //Assert.AreEqual(true, driver._isElementPresent("xpath", "//a[contains(@class,'CFT-auth-btn btn btn-default btn-block')]/span"), "'Try a different email address' Button not found on Page."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//a[@class='forgot-password' and text() = 'Forgot password?']"), "'Forgot password?' Link not found on Page."); Assert.AreEqual(true, driver._isElementPresent("xpath", "//a[text() = 'Trouble signing in?']"), "'Trouble signing in?' Link not found on Page."); Results.WriteStatus(test, "Pass", "Verified, Password Screen on Login Page."); return(new Login(driver, test)); }