Ejemplo n.º 1
0
        public void AddNewRole(string searchtext, string desctext)
        {
            Thread.Sleep(KortextGlobals.s);
            Klick.On(NewUserTypeButton);
            Thread.Sleep(KortextGlobals.s);

            Klick.On(RoleName);
            Thread.Sleep(KortextGlobals.s);
            WaitFind.FindElem(TypeNameDescTextField, 10).Clear();
            Klick.On(TypeNameDescTextField);
            Thread.Sleep(KortextGlobals.s);
            TypeNameDescTextField.SendKeys(searchtext);
            Thread.Sleep(KortextGlobals.s);
            Klick.On(NameDescSubmitButton);

            Klick.On(RoleDesc);
            Thread.Sleep(KortextGlobals.s);
            WaitFind.FindElem(TypeNameDescTextField, 10).Clear();
            Klick.On(TypeNameDescTextField);
            Thread.Sleep(KortextGlobals.s);
            TypeNameDescTextField.SendKeys(desctext);
            Thread.Sleep(KortextGlobals.s);
            Klick.On(NameDescSubmitButton);
            statusreturntext = Pages.PearlEditBuffer.StatusMessage();
            if (statusreturntext != "User type created")
            {
                Console.WriteLine("Error while Creating a User Role." + statusreturntext);
            }
            else
            {
                Console.WriteLine("User Role Created Successful");
            }
            SearchRoles(searchtext);
        }
Ejemplo n.º 2
0
        public void UpdateRole(string rolenm, string rolefield, string newtext)
        {
            Driver.Instance.Navigate().Refresh();
            Thread.Sleep(KortextGlobals.l);

            List <NgWebElement> UserTypesSearched = new List <NgWebElement>(Driver.ngDriver.FindElements(NgBy.Repeater("usertype in usertypes.US.allUsertypes track by usertype.id")));

            if (UserTypesSearched.Count > 0)
            {
                foreach (IWebElement UserTypeSearched in UserTypesSearched)
                {
                    Driver.HighlightElement(UserTypeSearched);
                    IWebElement UserTypeTitle = UserTypeSearched.FindElement(TitleUserTypeName_locator);
                    if (UserTypeTitle.Text == (rolenm + " expand_more"))
                    {
                        Klick.On(UserTypeTitle);
                        Thread.Sleep(KortextGlobals.s);
                        ((IJavaScriptExecutor)Driver.Instance).ExecuteScript("arguments[0].scrollIntoView(true);", UserTypeTitle);
                        Thread.Sleep(KortextGlobals.s);

                        if (rolefield == "Name")
                        {
                            IWebElement UserTypeName = UserTypeSearched.FindElement(UserTypeName_locator);
                            Klick.On(UserTypeName);
                            Thread.Sleep(KortextGlobals.s);
                            WaitFind.FindElem(TypeNameDescTextField, 10).Clear();
                            Klick.On(TypeNameDescTextField);
                            Thread.Sleep(KortextGlobals.s);
                            TypeNameDescTextField.SendKeys(newtext);
                            Thread.Sleep(KortextGlobals.s);
                            Klick.On(NameDescSubmitButton);
                            statusreturntext = Pages.PearlEditBuffer.StatusMessage();
                            if (statusreturntext != "User type updated")
                            {
                                Console.WriteLine("Error while Updating User Role Name." + statusreturntext);
                            }
                            else
                            {
                                Console.WriteLine("User Role Name Update Successful");
                            }
                        }
                        else if (rolefield == "Description")
                        {
                            IWebElement UserTypeDesc = UserTypeSearched.FindElement(UserTypeDesc_locator);
                            Klick.On(UserTypeDesc);
                            Thread.Sleep(KortextGlobals.s);
                            WaitFind.FindElem(TypeNameDescTextField, 10).Clear();
                            Klick.On(TypeNameDescTextField);
                            Thread.Sleep(KortextGlobals.s);
                            TypeNameDescTextField.SendKeys(newtext);
                            Thread.Sleep(KortextGlobals.s);
                            Klick.On(NameDescSubmitButton);
                            statusreturntext = Pages.PearlEditBuffer.StatusMessage();
                            if (statusreturntext != "User type updated")
                            {
                                Console.WriteLine("Error while Updating User Role Description." + statusreturntext);
                            }
                            else
                            {
                                Console.WriteLine("User Role Description Update Successful");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Incorrect Role Field passed to the function.");
                        }
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine(rolenm + " Role not found to be updated");
            }
        }