using LoginPI.Engine.ScriptBase; using System; public class MicrosoftDynamicsCRM365 : ScriptBase { void Execute() { /* Workload developed with: -iexplore version 11.557.17763.0 -winver 1809 (os build 17763.557) This script will: -Open iexplore web browser -Navigate to Dynamics CRM login page -Log in with user credentials -Navigate to Sales Hub page -Navigate to Leads page -Perform query for a specified Lead name -Open the resultant Lead, from the query -Navigate to Accounts page -Perform query for a specified Account name -Open the resultant Account, from the query -Logout of Dynamics CRM user -Close the web browser Please update the following in this file (there might be multiple instances): -" " with what the target Dynamics URL really is -" " with the account name (e.g. Username1) -" " with the email addresses domain (e.g. gmail.com) -" " with the user's (email address account's) password -" " with the name of an existing singular Lead name in the CRM database (recommended the search query for this Lead name will yield only one Lead result) -" " with the name of an existing singular account name in the CRM database (recommended the search query for this Account name will yield only one Lead result) Other: -In this script the example account's CRM landing page (Default Tab) is the "My Apps" page. This can be configured to be the default/landing page in the account Settings -timeout values for metafunctions are commonly set to 60 seconds throughout this script (for example, for when waiting for a button to appear). These can be updated as higher, if need be */ // Making sure iexplore isn't already open ShellExecute("cmd /c taskkill /f /im iexplo*",waitForProcessEnd:true,timeout:15); // Opening iexplore; inprivate mode START(mainWindowTitle:"*InPrivate*",timeout:60); // Starting login process: focusing on iexplore address bar's presence; clicking on it var AddressBar = MainWindow.FindControlWithXPath(xPath : "Pane:ReBarWindow32/Pane:Address Band Root/ToolBar:ToolbarWindow32/MenuItem[1]",timeout:60); AddressBar.DoubleClick(); AddressBar.Click(); Wait(seconds:3); // Typing and entering Type("{enter}",cpm:999); // Making var for username field -> clicking -> typing {@} and enter var UsernameField = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group[1]/Edit",timeout:60); Wait(seconds:3); UsernameField.Click(); Wait(seconds:3); Type("{@}",cpm:999); Wait(seconds:3); Type("{enter}"); Wait(seconds:3); // Making var for password field -> clicking on field -> typing password -> typing enter var PasswordField = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group[1]/Edit",timeout:60); Wait(seconds:3); PasswordField.Click(); Wait(seconds:3); Type("",cpm:999); Wait(seconds:3); Type("{enter}"); // Make var for "Yes" button on "Stay signed in?" page -> clicking on it -> starting custom timer (for CRM initial landing page load) Wait(seconds:3); var YesButton = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group[1]/Button[1]",timeout:60); Wait(seconds:3); YesButton.Click(); StartTimer("CRM_LandingPage_Load"); // Looking for the Published Apps text/drop down button, which should only be present when the landing page is loaded. In this example, in the account Settings, My Apps is configured as the Default Tab setting MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group[1]/Pane/Pane/Button[3]/Text",timeout:60); StopTimer("CRM_LandingPage_Load"); Wait(3); // Navigating to the Sales Hub page: making var for drop down button (next to Dynamics 365 logo) -> clicking button -> making var for Sales Hub button -> clicking button -> starting timer for Sales Hub page loading Wait(seconds:3); var Dynamics365DropDown = MainWindow.FindControl(className : "Hyperlink", title : "Switch to another app",timeout:60); Wait(seconds:3); Dynamics365DropDown.Click(); Wait(seconds:3); var SalesHubButton = MainWindow.FindControl(className : "Button", title : "Sales Hub",timeout:60); Wait(seconds:3); SalesHubButton.Click(); StartTimer("CRM_SalesHub_Load"); // Looking for something that is present when the page has loaded, which is "Actual Revenue by Fiscal Period", in this case MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Group/Group[1]/Text[1]",timeout:60); StopTimer("CRM_SalesHub_Load"); // Navigating to Leads page: making var for Leads button on the left sidebar -> clicking -> starting custom timer for the Leads page loading var LeadsButton = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Text[1]/Tree[1]/TreeItem[2]/Group[1]/TreeItem/Group",timeout:60); LeadsButton.Click(); StartTimer("CRM_LeadsLandingPage_Load"); // Waiting for something on the Leads page to be present; this is encapsulated by a custom timer function --- populating a var for the "Search for Records" field -> stoping timer -> clicking search for records field var SearchForRecordsButton = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Edit",timeout:60); StopTimer("CRM_LeadsLandingPage_load"); Wait(seconds:3); SearchForRecordsButton.Click(); // Typing in " " and enter Type("{enter}",cpm:999); // Waiting for result (link) to be present; this is encapsulated by a custom timer function -> clicking StartTimer("CRM_LeadsQueryPage_Load"); var LeadsQueryResultLink = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Group[1]/Group/DataGrid/Group[1]/DataItem[1]/Hyperlink",timeout:60); StopTimer("CRM_LeadsQueryPage_Load"); Wait(seconds:3); LeadsQueryResultLink.Click(); // Waiting for lead record page to load; this is encapsulated by a custom timer function (looking for the CONTACT string) StartTimer("CRM_Lead_Load_Time"); MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Group/Group/Pane/Text/Text",timeout:60); StopTimer("CRM_Lead_Load_Time"); // Navigating to Accounts page: populating Accounts button var from the left sidebar -> clicking on Accounts button -> starting custom timer var AccountsPageButton = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Text[1]/Tree[1]/TreeItem[1]/Group[1]/TreeItem/Group",timeout:60); Wait(seconds:3); AccountsPageButton.Click(); StartTimer("CRM_AccountsLandingPage_load"); // Waiting for something on the Account page to be present; this is encapsulated by custom timer function (looking for Last Sales Activity column header) MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Group[1]/Group/DataGrid/Group/HeaderItem[1]/Text",timeout:60); StopTimer("CRM_AccountsLandingPage_load"); Wait(seconds:3); // Saving Search for Records field as variable -> Clicking it var SearchForRecordsAccounts = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Edit",timeout:60); SearchForRecordsAccounts.Click(); Wait(seconds:3); // Typing in " " and enter Type("{enter}",cpm:999); // Waiting for result to be present; this is encapsulated by custom timer function -> clicking on it StartTimer("CRM_AccountsQueryPage_load"); var LoginVSIAccountLink = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Group[1]/Group/DataGrid/Group[1]/DataItem[1]/Hyperlink",timeout:60); StopTimer("CRM_AccountsQueryPage_load"); Wait(seconds:3); LoginVSIAccountLink.Click(); // Waiting for account record page to load; encapsulated by custom timer function (looking for Account Name text string) StartTimer("CRM_AccountResultOpening_Load_Time"); MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group/Group/Group/Pane/Text/Group/Text",timeout:60); StopTimer("CRM_AccountResultOpening_Load_Time"); // Clicking on the Account button in upper-right -> clicking on Logout var AccountLogoutButton = MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/MenuBar[2]/MenuItem",timeout:60); AccountLogoutButton.Click(); Wait(seconds:3); Type("{down}".Repeat(2)); Type("{enter}",cpm:999); // Making sure the account gets logged out, by looking for the "Use Another Account" string StartTimer("CRM_LoggedOut_Time"); MainWindow.FindControlWithXPath(xPath : "Pane:Frame Tab/Pane:TabWindowClass/Pane:Shell DocObject View/Pane:Internet Explorer_Server/Pane/Group[1]/List/ListItem[1]/Text",timeout:60); StopTimer("CRM_LoggedOut_Time"); // Stopping App STOP(timeout:60); } }