public void ATC4422_CRMTenancyRequestWithNoContributor() { #region Start Up Excel MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()]; MyRange = MySheet.UsedRange; //Get specific row for the data int testDataRows = MyRange.Rows.Count; int MyRow = 0; for (int i = 2; i <= testDataRows; i++) { if (MyRange.Cells[i, 1].Value.ToString() == "TR_TestData") { MyRow = i; break; } } #endregion string initialRequestParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString(); string initialContribution = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString(); string rentalPremises = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString(); //Login as RBS user User user = this.environment.GetUser(SecurityRole.RBSOfficer); new LoginDialog().Login(user.Id, user.Password); //As a RBS Officer, navigate to an Address Detail HomePage homePage = new HomePage(driver); homePage.HoverCRMRibbonTab(); homePage.ClickRBSRibbonButton(); homePage.HoverRBSRibbonTab(); homePage.ClickRtaAddressDetailRibbonButton(); AddressDetailSearchPage addressDetailSearchPage = new AddressDetailSearchPage(driver); addressDetailSearchPage.SetAddressDetailSearchText("MITCHELTON"); Table addressSearchTable = new Table(addressDetailSearchPage.GetSearchResultTable()); addressSearchTable.ClickCellContainsValue("Name", rentalPremises, "Name"); AddressDetailPage addressDetailPage = new AddressDetailPage(driver); //Click on the Tenancy Requests Associated View in the dropdown ribbon menu homePage.HoverAddressDetailRibbonTab(rentalPremises); homePage.ClickTRAddressDetailViewRibbonButton(); addressDetailPage = new AddressDetailPage(driver); string BaseWindow = driver.CurrentWindowHandle; addressDetailPage.ClickAddNewTenancyRequestButton(); addressDetailPage.SwitchNewBrowser(driver, BaseWindow); //Fill in all mandatory details and Click Save&close TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver); tenancyRequestPage.ClickPageTitle(); //Set {Type} field to Bond Lodgement. tenancyRequestPage.SetRequestTypeListValue("Bond Lodgement"); tenancyRequestPage.PopulateTenancyRequestWithoutRentalPremisesFromAddressDetailAssociatedView( MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("NO_ROOMS")].Value.ToString(), initialRequestParty, MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(), initialContribution, MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString()); tenancyRequestPage.SetDwellingTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("DWELLING_TYPE")].Value.ToString()); tenancyRequestPage.ClickSaveButton(); string tenancyRequest = tenancyRequestPage.GetRequestNumber(); StringAssert.Contains(tenancyRequest, "TR-BL-", "Validating the Tenancy Request saved with the correct TR no fromat"); tenancyRequestPage.ClickSaveCloseButton(); driver = driver.SwitchTo().Window(BaseWindow); //Open the Tenancy Request which was just created addressDetailPage = new AddressDetailPage(driver); addressDetailPage.SetTenancyRequestSearchText(tenancyRequest); Table tenancyRequestSearchTable = new Table(addressDetailPage.GetTenancyRequestSearchResultTable()); tenancyRequestSearchTable.ClickCellContainsValue("Name", tenancyRequest, "Name"); tenancyRequestPage = new TenancyRequestPage(driver); tenancyRequestPage.ClickPageTitle(); Table requestPartyTable = new Table(tenancyRequestPage.GetRequestPartyTable()); //Confirm the tenancy request has only one contributor i.e initial Request Party Assert.AreEqual(requestPartyTable.GetCellContainsValue("Request Amount",initialContribution,"Client"), initialRequestParty); Assert.AreEqual(1, requestPartyTable.GetRowCount()-1,"Validating only one contributor is avaialble"); UICommon.DoubleClickElement(requestPartyTable.GetCellElementContainsValue("Client", initialRequestParty, "Client"), driver); Thread.Sleep(1000); TenancyRequestPartyPage tenancyRequestPartyPage = new TenancyRequestPartyPage(driver); tenancyRequestPartyPage.ClickPageTitle(); //Try to deactivate the contributor. Fails with an error dialog tenancyRequestPartyPage.ClickDeactivateButton(); WarningDialogueFramePage warningPage = new WarningDialogueFramePage(driver); warningPage.ClickProcessBeginButton(); tenancyRequestPartyPage.ClickSaveCloseButton(); //Go back to tenancy request form. The Delete button should not be available for RBS user tenancyRequestPage = new TenancyRequestPage(driver); tenancyRequestPage.ClickPageTitle(); requestPartyTable = new Table(tenancyRequestPage.GetRequestPartyTable()); Assert.AreEqual(requestPartyTable.GetCellContainsValue("Request Amount", initialContribution, "Client"), initialRequestParty); Assert.AreEqual(1, requestPartyTable.GetRowCount() - 1, "Validating the initial contributor is still avaialble after trying to deactivate"); IWebElement element = requestPartyTable.GetCellElementContainsValue("Client", initialRequestParty, "Request Amount"); Assert.IsFalse(tenancyRequestPage.ClickDeleteButtonIfDisplayed(element),"Validating that delete button not displyed to click"); #region Shut down Excel MyBook.Save(); MyBook.Close(); MyApp.Quit(); #endregion }