public void ClosePendingEmailReminder()
        {
            using (var xrmBrowser = new Microsoft.Dynamics365.UIAutomation.Api.Browser(TestSettings.Options))
            {
                xrmBrowser.LoginPage.Login(_xrmUri, pscWasteUserName1, pscWastePassword1);

                try
                {
                    xrmBrowser.GuidedHelp.CloseGuidedHelp();
                }
                catch { }

                xrmBrowser.ThinkTime(2000);
                try
                {
                    xrmBrowser.Dialogs.CloseWarningDialog();
                }
                catch
                {
                }

                xrmBrowser.ThinkTime(2000);
                xrmBrowser.Navigation.OpenSubArea("LP", "Applications");

                xrmBrowser.ThinkTime(2000);
                xrmBrowser.Grid.SwitchView("Active Applications");

                xrmBrowser.ThinkTime(1000);
                xrmBrowser.Grid.OpenRecord(0);
                xrmBrowser.ThinkTime(1000);
            }
        }
        public void OpenApplication()
        {
            using (var xrmBrowser = new Microsoft.Dynamics365.UIAutomation.Api.Browser(TestSettings.Options))
            {
                xrmBrowser.LoginPage.Login(_xrmUri, pscWasteUserName1, pscWastePassword1);
                xrmBrowser.ThinkTime(500);
                try { xrmBrowser.GuidedHelp.CloseGuidedHelp(); }
                catch { }

                xrmBrowser.ThinkTime(2000);
                try
                { xrmBrowser.Dialogs.CloseWarningDialog(); }
                catch { }

                xrmBrowser.Navigation.OpenSubArea("LP", "Applications");
                xrmBrowser.Grid.SwitchView("Active Applications");
                xrmBrowser.Grid.Search("*WE");
                xrmBrowser.Grid.OpenRecord(0);
                xrmBrowser.ThinkTime(10000);
                // do
                // {
                //    xrmBrowser.ThinkTime(500);
                //     var id = OpenQA.Selenium.By.Id("Application Type_label");
                //    statusText = xrmBrowser.Driver.FindElement(id).Text;
                //  } while (statusText == "New Application");
                //  Assert.IsTrue(String.IsNullOrEmpty(statusText), statusText);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Closes the Notifications
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Notifications.CloseNotifications();</example>
        public BrowserCommandResult <bool> CloseNotifications(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute("Close Notifications", driver =>
            {
                bool returnValue = false;

                driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.Notification.AppMessageBar]), new TimeSpan(0, 0, 5), d =>
                {
                    var container = driver.FindElement(By.XPath(Elements.Xpath[Reference.Notification.AppMessageBar]));
                    var rows = container.FindElements(By.ClassName(Elements.CssClass[Reference.Notification.MessageBarRow]));

                    foreach (var row in rows)
                    {
                        var dismissButtonElement = row.FindElement(By.ClassName(Elements.CssClass[Reference.Notification.MessageBarButtonContainer]));
                        var dismissButton = dismissButtonElement.FindElement(By.TagName("a"));

                        dismissButton.Click();

                        returnValue = true;
                    }
                });

                return returnValue;
            }));
        }
Esempio n. 4
0
        public BrowserCommandResult <bool> OpenFeature(string name, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Open Feature"), driver =>
            {
                var container = driver.FindElement(By.ClassName("content"));
                var items = container.FindElements(By.TagName("a"));

                var itemExists = false;
                foreach (var item in items)
                {
                    if (String.Equals(item.Text, name, StringComparison.OrdinalIgnoreCase))
                    {
                        itemExists = true;
                        item.Click();
                    }
                }

                if (!itemExists)
                {
                    throw new InvalidOperationException($"The Feature {name} does not exist.");
                }

                return true;
            }));
        }
Esempio n. 5
0
        /// <summary>
        /// Global Search
        /// </summary>
        /// <param name="searchText">The SearchText</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.GlobalSearch("Contoso");</example>
        public BrowserCommandResult <bool> GlobalSearch(string searchText, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Global Search: {searchText}"), driver =>
            {
                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Navigation.SearchButton]),
                                          new TimeSpan(0, 0, 5),
                                          "The Global Search button is not available.");

                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Navigation.SearchLabel]), TimeSpan.FromSeconds(1));

                driver.WaitUntilClickable(By.XPath(Elements.Xpath[Reference.Navigation.Search]),
                                          new TimeSpan(0, 0, 5),
                                          e =>
                {
                    e.SendKeys(searchText, true);
                    Browser.ThinkTime(500);
                    e.SendKeys(Keys.Enter);
                },
                                          "The Global Search text field is not available."
                                          );

                return true;
            }));
        }
Esempio n. 6
0
        /// <summary>
        /// Switches between the DashBoard.
        /// </summary>
        /// <param name="dashBoardName">The name of the DashBoard you want to select</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Dashboard.SelectDashBoard("Sales Performance Dashboard");</example>
        public BrowserCommandResult <bool> SelectDashBoard(string dashBoardName, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Select Dashboard"), driver =>
            {
                Dictionary <string, System.Guid> dashboards = OpenViewPicker();

                if (!dashboards.ContainsKey(dashBoardName))
                {
                    throw new InvalidOperationException($"Dashboard '{dashBoardName}' does not exist in the dashboard select options");
                }

                var viewId = dashboards[dashBoardName];

                // Get the LI element with the ID {guid} for the ViewId.
                var viewContainer = driver.WaitUntilAvailable(By.Id(viewId.ToString("B")));
                var viewItems = viewContainer.FindElements(By.TagName("a"));

                foreach (var viewItem in viewItems)
                {
                    if (viewItem.Text == dashBoardName)
                    {
                        viewItem.Click();
                    }
                }

                return true;
            }));
        }
Esempio n. 7
0
        /// <summary>
        /// Switches from one view to another
        /// </summary>
        /// <param name="viewName">Name of the view to which you want to switch</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Related.SwitchView("Active Cases");</example>
        public BrowserCommandResult <bool> SwitchView(string viewName, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Switch View"), driver =>
            {
                var views = OpenViewPicker().Value;

                if (!views.ContainsKey(viewName))
                {
                    throw new InvalidOperationException($"No view with the name '{viewName}' exists.");
                }
                var viewId = views[viewName];

                // Get the LI element with the ID {guid} for the ViewId.
                var viewContainer = driver.WaitUntilAvailable(By.Id(viewId.ToString("B").ToUpper()));
                var viewItems = viewContainer.FindElements(By.TagName("a"));

                foreach (var viewItem in viewItems)
                {
                    if (viewItem.Text == viewName)
                    {
                        viewItem.Click();
                    }
                }

                return true;
            }));
        }
        /// <summary>
        /// Filters the by letter.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Grid.FilterByLetter('A');</example>
        /// <exception cref="System.InvalidOperationException">Filter criteria is not valid.</exception>
        public BrowserCommandResult <bool> FilterByLetter(char filter, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            if (!Char.IsLetter(filter) && filter != '#')
            {
                throw new InvalidOperationException("Filter criteria is not valid.");
            }

            return(this.Execute(GetOptions("Filter by Letter"), driver =>
            {
                var jumpBar = driver.FindElement(By.XPath(Elements.Xpath[Reference.Grid.JumpBar]));
                var letterCells = jumpBar.FindElements(By.TagName("TD"));

                foreach (var letter in letterCells)
                {
                    if (letter.Text == filter.ToString())
                    {
                        letter.Click();
                    }
                }

                return true;
            }));
        }
Esempio n. 9
0
        /// <summary>
        /// Filter by entity in the Global Search Results.
        /// </summary>
        /// <param name="entity">The entity you want to filter with.</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.GlobalSearch.FilterWith("Account");</example>
        public BrowserCommandResult <bool> FilterWith(string entity, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Filter With: {entity}"), driver =>
            {
                if (!driver.HasElement(By.XPath(Elements.Xpath[Reference.GlobalSearch.Filter])))
                {
                    throw new InvalidOperationException("Filter With picklist is not available");
                }

                var picklist = driver.FindElement(By.XPath(Elements.Xpath[Reference.GlobalSearch.Filter]));
                var options = driver.FindElements(By.TagName("option"));

                picklist.Click();

                IWebElement select = options.FirstOrDefault(x => x.Text == entity);

                if (select == null)
                {
                    throw new InvalidOperationException($"Entity '{entity}' does not exist in the Filter options.");
                }

                select.Click();

                return true;
            }));
        }
 internal void FillJobOrderFormAndSave(Api.Browser xrmBrowser, String employerName, String info)
 {
     this.xrmBrowser = xrmBrowser;
     xrmBrowser.ThinkTime(1500);
     this.employerName = employerName;
     employerName      = xrmBrowser.JobOrder.FillJobOrderFormAndSave(employerName, info, 2000);
 }
Esempio n. 11
0
        /// <summary>
        /// Opens the Menu
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        public BrowserCommandResult <Dictionary <string, IWebElement> > OpenMenu(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Open Menu Menu"), driver =>
            {
                var dictionary = new Dictionary <string, IWebElement>();

                driver.WaitUntilAvailable(By.ClassName(Elements.CssClass[Reference.Navigation.TopLevelItem]));

                var topItem = driver.FindElements(By.ClassName(Elements.CssClass[Reference.Navigation.TopLevelItem])).FirstOrDefault();
                topItem?.FindElement(By.Name(Elements.Name[Reference.Navigation.HomeTab])).Click();

                driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Navigation.Employers]));

                var element = driver.FindElement(By.XPath(Elements.Xpath[Reference.Navigation.Employers]));
                var subItems = element.FindElements(By.ClassName(Elements.CssClass[Reference.Navigation.ActionButtonContainer]));

                foreach (var subItem in subItems)
                {
                    dictionary.Add(subItem.GetAttribute("title").ToLowerString(), subItem);
                }

                return dictionary;
            }));
        }
        /// <summary>
        /// Clicks the  Command
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="subName">The subName</param>
        /// <param name="moreCommands">The moreCommands</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Related.ClickCommand("ADD NEW CASE");</example>
        public BrowserCommandResult <bool> ClickCommand(string name, string subName = "", bool moreCommands = false, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("ClickCommand"), driver =>
            {
                if (moreCommands)
                {
                    driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.CommandBar.MoreCommands]));
                }

                var buttons = GetCommands(moreCommands).Value;
                var button = buttons.FirstOrDefault(x => x.Text.ToLowerString() == name.ToLowerString());

                if (button == null)
                {
                    throw new Exception($"Command Button with name: {name} does not exist.");
                }

                if (string.IsNullOrEmpty(subName))
                {
                    button.Click();
                }
                else
                {
                    button.FindElement(By.ClassName(Elements.CssClass[Reference.CommandBar.FlyoutAnchorArrow])).Click();

                    var flyoutId = button.GetAttribute("id").Replace("|", "_").Replace(".", "_") + "Menu";
                    var subButtons = driver.FindElement(By.Id(flyoutId)).FindElements(By.TagName("li"));
                    subButtons.Where(x => x.Text.ToLower() == subName.ToLower()).FirstOrDefault()?.Click();
                }

                return true;
            }));
        }
Esempio n. 13
0
        public BrowserCommandResult <bool> CreateProcess(string name, ProcessType type, string entity, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Create Process"), driver =>
            {
                SwitchToDialogFrame();

                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Process.Name]))
                .SendKeys(name);

                SetValue(new OptionSet()
                {
                    Name = Elements.ElementId[Reference.Process.Category], Value = type.ToString()
                });
                SetValue(new OptionSet()
                {
                    Name = Elements.ElementId[Reference.Process.Entity], Value = entity
                });

                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Process.BlankWorkflow]));

                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Process.Create]));

                return true;
            }));
        }
Esempio n. 14
0
        public BrowserCommandResult <bool> OpenHomePage(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            //TODO: Implement HomePage logic
            throw new NotImplementedException();
        }
Esempio n. 15
0
        /// <summary>
        /// Selects Item based on the value given
        /// </summary>
        /// <param name="value">The value</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Lookup.SelectItem("Alex Wu");</example>
        public BrowserCommandResult <bool> SelectItem(string value, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Select Item"), driver =>
            {
                var itemsTable = driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Grid.GridBodyTable]));

                if (itemsTable.GetAttribute("totalrecordcount") == "0")
                {
                    throw new InvalidOperationException($"No Process records are available in this view for the Search'{value}'");
                }
                var tbody = itemsTable.FindElement(By.TagName("tbody"));
                var items = tbody.FindElements(By.TagName("tr"));

                foreach (var item in items)
                {
                    var primary = item.FindElements(By.TagName("td"))[1];
                    if (primary.Text == value)
                    {
                        var checkbox = item.FindElements(By.TagName("td"))[0];

                        if (item.GetAttribute("selected") != "true")
                        {
                            checkbox.Click();
                        }
                        break;
                    }
                }

                return true;
            }));
        }
Esempio n. 16
0
        /// <summary>
        /// Global Search
        /// </summary>
        /// <param name="searchText">The SearchText</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.GlobalSearch("Contoso");</example>
        public BrowserCommandResult <bool> GlobalSearch(string searchText, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Global Search: {searchText}"), driver =>
            {
                driver.WaitUntilClickable(By.XPath(Elements.Xpath[Reference.Navigation.SearchButton]),
                                          new TimeSpan(0, 0, 5),
                                          d => { driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Navigation.SearchButton])); },
                                          d => { throw new InvalidOperationException("The Global Search button is not available."); });


                if (driver.IsVisible(By.XPath(Elements.Xpath[Reference.Navigation.SearchLabel])))
                {
                    driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Navigation.SearchLabel]));
                }

                driver.WaitUntilClickable(By.XPath(Elements.Xpath[Reference.Navigation.Search]),
                                          new TimeSpan(0, 0, 5),
                                          d =>
                {
                    driver.FindElement(By.XPath(Elements.Xpath[Reference.Navigation.Search])).SendKeys(searchText, true);
                    driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Navigation.StartSearch]));
                },
                                          d => { throw new InvalidOperationException("The Global Search text field is not available."); });

                return true;
            }));
        }
Esempio n. 17
0
        /// <summary>
        /// Open Quick Create
        /// </summary>
        /// <param name="entity">The entity name</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.QuickCreate("Account");</example>
        public BrowserCommandResult <bool> QuickCreate(string entity, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Open Quick Create"), driver =>
            {
                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Navigation.GlobalCreate]));

                driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.QuickCreate.EntityContainer]), new TimeSpan(0, 0, 2));

                var area = driver.FindElement(By.XPath(Elements.Xpath[Reference.QuickCreate.EntityContainer]));
                var items = area.FindElements(By.TagName("a"));

                var item = items.FirstOrDefault(x => x.Text == entity);

                if (item == null)
                {
                    throw new InvalidOperationException($"No Entity with the name '{entity}' exists inside QuickCreate.");
                }

                item.Click(true);

                driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.QuickCreate.Container]));

                return true;
            }));
        }
Esempio n. 18
0
        /// <summary>
        /// Opens the Sub Area
        /// </summary>
        /// <param name="area">The area you want to open</param>
        /// <param name="subArea">The subarea you want to open</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.OpenSubArea("Sales", "Opportunities");</example>
        public BrowserCommandResult <bool> OpenSubArea(string area, string subArea, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($": {area} > {subArea}"), driver =>
            {
                area = area.ToLower();
                subArea = subArea.ToLower();

                var areas = OpenMenu().Value;

                if (!areas.ContainsKey(area))
                {
                    throw new InvalidOperationException($"No area with the name '{area}' exists.");
                }

                var subAreas = OpenSubMenu(areas[area]).Value;

                if (!subAreas.ContainsKey(subArea))
                {
                    throw new InvalidOperationException($"No subarea with the name '{subArea}' exists inside of '{area}'.");
                }

                subAreas[subArea].Click();

                SwitchToContent();
                driver.WaitForPageToLoad();

                return true;
            }));
        }
Esempio n. 19
0
        /// <summary>
        /// Set Lookup Value for Subgrid subgridName
        /// </summary>
        /// <param name="subgridName">The SubgridName</param>
        /// <param name="value"></param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Entity.SelectSubgridLookup("Stakeholders", "Alex Wu");</example>
        public BrowserCommandResult <bool> SelectSubgridLookup(string subgridName, string value, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Set Lookup Value for Subgrid {subgridName}"), driver =>
            {
                if (driver.HasElement(By.Id($"inlineLookupControlForSubgrid_{subgridName}")))
                {
                    var input = driver.ClickWhenAvailable(By.Id($"inlineLookupControlForSubgrid_{subgridName}"));

                    var lookupIcon = input.FindElement(By.ClassName(Elements.CssClass[Reference.Entity.LookupRender]));
                    lookupIcon.Click();

                    var dialogName = $"Dialog_lookup_{subgridName}_i_IMenu";
                    var dialog = driver.FindElement(By.Id(dialogName));

                    var dialogItems = OpenDialog(dialog).Value;

                    if (!dialogItems.Exists(x => x.Title == value))
                    {
                        throw new InvalidOperationException($"List does not have {value}.");
                    }

                    var dialogItem = dialogItems.Where(x => x.Title == value).First();
                    dialogItem.Element.Click();
                }

                return true;
            }));
        }
Esempio n. 20
0
        /// <summary>
        /// Clicks the  Command
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="subName">The subName</param>
        /// <param name="moreCommands">The moreCommands</param>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Related.ClickCommand("ADD NEW CASE");</example>
        public BrowserCommandResult <bool> ClickCommand(string name, string subName = "", bool moreCommands = false, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Click Command"), driver =>
            {
                ClickCommandButton(name, subName, moreCommands, thinkTime);
                return true;
            }));
        }
Esempio n. 21
0
        /// <summary>
        /// Closes the chart.
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Grid.CloseChart();</example>
        public BrowserCommandResult <bool> CloseChart(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("CloseChart"), driver =>
            {
                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Grid.CloseChart]));
                return true;
            }));
        }
Esempio n. 22
0
        public BrowserCommandResult <bool> ClickCommandbyLink(string name, string subName = "", bool moreCommands = false, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Click Command By link"), driver =>
            {
                driver.FindElement(By.LinkText(name)).Click();
                return true;
            }));
        }
        /// <summary>
        /// Opens the view picker.
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        public BrowserCommandResult <Dictionary <string, Guid> > OpenViewPicker(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute("Open View Picker", driver =>
            {
                var dictionary = new Dictionary <string, Guid>();

                var dashboardSelectorContainer = driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.DashBoard.Selector]));
                dashboardSelectorContainer.FindElement(By.TagName("a")).Click();

                //Handle Firefox not clicking the viewpicker the first time
                driver.WaitUntilVisible(By.ClassName(Elements.CssClass[Reference.DashBoard.ViewContainerClass]),
                                        TimeSpan.FromSeconds(2),
                                        failureCallback: () => dashboardSelectorContainer.FindElement(By.TagName("a")).Click());

                var viewContainer = driver.WaitUntilAvailable(By.ClassName(Elements.CssClass[Reference.DashBoard.ViewContainerClass]));
                var viewItems = viewContainer.FindElements(By.TagName("li"));

                foreach (var viewItem in viewItems)
                {
                    var role = viewItem.GetAttribute("role");
                    if (role != "menuitem")
                    {
                        continue;
                    }

                    var links = viewItem.FindElements(By.TagName("a"));
                    if (links == null || links.Count <= 1)
                    {
                        continue;
                    }

                    //var title = links[1].GetAttribute("title");
                    var tag = links[1].FindElement(By.TagName("nobr"));
                    var name = tag.Text;
                    Guid guid;

                    var parseSuccess = Guid.TryParse(viewItem.GetAttribute("id"), out guid);
                    if (!parseSuccess)
                    {
                        continue;
                    }

                    //Handle Duplicate View Names
                    //Temp Fix
                    if (!dictionary.ContainsKey(name))
                    {
                        dictionary.Add(name, guid);
                    }
                }

                return dictionary;
            }));
        }
Esempio n. 24
0
        /// <summary>
        /// Opens the view picker.
        /// </summary>
        public BrowserCommandResult <Dictionary <string, Guid> > OpenViewPicker(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Open View Picker"), driver =>
            {
                var xpathToViewSelector = By.XPath(Elements.Xpath[Reference.Grid.ViewSelector]);
                driver.ClickWhenAvailable(xpathToViewSelector, TimeSpan.FromSeconds(20), "Unable to click the View Picker");

                var xpathToViewContainer = By.ClassName(Elements.CssClass[Reference.Grid.ViewContainer]);
                IWebElement viewContainer = driver.WaitUntilVisible(xpathToViewContainer, TimeSpan.FromSeconds(20));
                if (viewContainer == null)
                {
                    //Fix for Firefox not clicking the element in the event above. Issue with the driver.
                    driver.ClickWhenAvailable(xpathToViewSelector);
                    viewContainer = driver.WaitUntilVisible(xpathToViewContainer, TimeSpan.FromSeconds(3), "View Picker menu is not avilable");
                }

                var dictionary = new Dictionary <string, Guid>();
                var viewItems = viewContainer.FindElements(By.TagName("li"));

                foreach (var viewItem in viewItems)
                {
                    var role = viewItem.GetAttribute("role");
                    if (role != "menuitem")
                    {
                        continue;
                    }

                    var links = viewItem.FindElements(By.TagName("a"));
                    if (links.Count == 0)
                    {
                        continue;
                    }

                    var title = links[1].GetAttribute("title"); // TODO: Why is 1 instead 0?

                    var strId = viewItem.GetAttribute("id");
                    var parseSuccess = Guid.TryParse(strId, out var id);
                    if (!parseSuccess)
                    {
                        continue;
                    }

                    //Handle Duplicate View Names
                    //Temp Fix
                    if (!dictionary.ContainsKey(title))
                    {
                        dictionary.Add(title, id);
                    }
                }

                return dictionary;
            }));
        }
Esempio n. 25
0
        /// <summary>
        /// Opens the Guided Help
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.OpenGuidedHelp();</example>
        public BrowserCommandResult <bool> OpenGuidedHelp(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Open Guided Help"), driver =>
            {
                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Navigation.GuidedHelp]));

                return true;
            }));
        }
Esempio n. 26
0
        public BrowserCommandResult <bool> Cancel(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Cancel"), driver =>
            {
                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.LookUp.DialogCancel]));

                return true;
            }));
        }
Esempio n. 27
0
        /// <summary>
        /// Opens the Admin Portal
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.OpenAdminPortal();</example>
        public BrowserCommandResult <bool> OpenAdminPortal(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Open Admin Portal"), driver =>
            {
                driver.FindElement(By.XPath(Elements.Xpath[Reference.Navigation.AdminPortal]))?.Click();

                return true;
            }));
        }
Esempio n. 28
0
        /// <summary>
        /// Open Apps for Dynamics
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.OpenAppsForDynamicsCRM();</example>
        public BrowserCommandResult <bool> OpenAppsForDynamicsCRM(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Open Apps for Dynamics"), driver =>
            {
                OpenSettingsOption(driver, Elements.Xpath[Reference.Navigation.AppsForCRM]);

                return true;
            }));
        }
Esempio n. 29
0
        /// <summary>
        /// Opens OptOut Learning Path
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.OpenOptOutLearningPath();</example>
        public BrowserCommandResult <bool> OpenOptOutLearningPath(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Open Opt out of Learning Path"), driver =>
            {
                OpenSettingsOption(driver, Elements.Xpath[Reference.Navigation.OptOutLP]);

                return true;
            }));
        }
Esempio n. 30
0
        /// <summary>
        /// Opens the Privacy Statement
        /// </summary>
        /// <param name="thinkTime">Used to simulate a wait time between human interactions. The Default is 2 seconds.</param>
        /// <example>xrmBrowser.Navigation.OpenPrivacyStatement();</example>
        public BrowserCommandResult <bool> OpenPrivacyStatement(int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions($"Open Privacy Statement"), driver =>
            {
                OpenSettingsOption(driver, Elements.Xpath[Reference.Navigation.Privacy]);

                return true;
            }));
        }