コード例 #1
0
        public void ATC3350_CRMEntityClientAddressCreateNew()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Clients.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() == "3350")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string address = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("ADDRESS")].Value.ToString());

            //Login in as role
            User user = this.environment.GetUser(SecurityRole.SystemAdministrator);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Add New Address start:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetClientType("Person");
            clientPage.SetFamilyName("TESTING ADDRESS");
            clientPage.ClickSaveButton();
            string clientID = clientPage.GetClientID();
            homePage.HoverClientXRibbonTab("TESTING ADDRESS");
            homePage.ClickClientXAddressesRibbonButton();
            string BaseWindow = driver.CurrentWindowHandle;

            clientPage = new ClientPage(driver);
            Thread.Sleep(3000);
            clientPage.ClickAddNewClientAddressImage();
            driver = clientPage.SwitchNewBrowser(driver, BaseWindow, "Client Address:");
            ClientNewAddressPage clientNewAddressPage = new ClientNewAddressPage(driver);
            clientNewAddressPage.ClickPageTitle();
            clientNewAddressPage.SetAddressDetails("*" + address);
            clientNewAddressPage.ClickSaveButton();
            clientNewAddressPage.GetCleintAddress();

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Add New Address End:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            clientNewAddressPage.ClickSaveAndClose();

            driver = driver.SwitchTo().Window(BaseWindow);
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage = new ClientPage(driver);
            clientPage.SetPostalAddress("*" + address);
            clientPage.ClickSaveCloseButton();
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientID);
            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            Assert.AreEqual(table.GetCellValue("RTA Client Id", clientID, "Postal Address"), address, "Address comparison failed");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }