using LoginPI.Engine.ScriptBase; using System; public class salesforce : ScriptBase { void Execute() { /* -Disclaimer: This workload is provided as-is and might need further configuration and customization to work successfully in each unique environment. For further Professional Services-based customization please consult with the Login VSI Support and Services team. Please refer to the Help Center section "Application Customization" for further self-help information regarding workload crafting and implementation. -Run the workload against the "target" using Script Editor to ensure it will work before uploading it and testing with it -Go through the workload to understand what it's doing. Comment out any unneeded app tests (code blocks) or add on any needed functional testing -Workload version and changelist: --V1.0 | original -Developed with: -Leave Application running compatibility: true Read me, and to-dos: -There are vars at the top of this script which need to be set This script will: -Open web browser -Navigate to defined Salesforce login page -Log in with defined user credentials -Validate login based on home / landing page visibility -Open Opportunities page -Open Leads page -Open Accounts page -Open Contacts page -Seach in the Search Salesforce field for a defined database object (string) -Click on the defined result -Validate the search query result loads -Open the App Launcher page -Log out of the user -Close out of the web browser This script was created with the following versions, settings, and assumptions: -Firefox Quantum 67.0.4 x64 -Login PI ScriptingToolSet version 3.4.12 -Salesforce web UI version "Salesforce Summer ’19 Release" -Assuming the "Sales" page is the user's homepage / landing page -Assuming the Salesforce user will be presented the logon page every time Salesforce page initially navigated to in that web browser runtime session / instance */ // Declare string vars // var for address for Salesforce homepage string SalesforceHomepageAddress = "< Salesforce user login address >{enter}"; // vars for Salesforce username and password string userName = "< Salesforce username >"; string passWord = "< Salesforce password >"; // var for search / record query string (which database object to be searched for and click on, after querying, in the search field (e.g. Account name, Lead name, etc.)). Preffered for the search object/string to be unique enough to yield only one result string SearchRecordQueryString = "< Search record query string >"; // Closing out of the web browser if already running (to prepare for new test) ShellExecute("cmd /c taskkill /f /im firef*",waitForProcessEnd:true,timeout:60); // Starting web browser; navigating to < Salesforce login page > START(mainWindowTitle:"*Mozilla Firefox*",timeout:20); MainWindow.Focus(); MainWindow.Maximize(); MainWindow.FindControl(className : "Button", title : "Home",timeout:60); KeyDown(KeyCode.ALT); Type("d",cpm:9999); KeyUp(KeyCode.ALT); Wait(1); Type(SalesforceHomepageAddress,cpm:9999); // Logging into Salesforce with < username > and < password > StartTimer(name:"LoginPageDisplayed"); var SalesForceLoginWindow = FindWindow(title : "*Login | Salesforce*",timeout:60); SalesForceLoginWindow.Focus(); var UsernameField = SalesForceLoginWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown/Unknown/Unknown[1]/Unknown/Unknown/Unknown[1]/Unknown/Edit",timeout:60); StopTimer(name:"LoginPageDisplayed"); UsernameField.Click(); Wait(2); Type(userName,cpm:9999); Type("{TAB}",cpm:9999); Wait(0.5); Type(passWord,cpm:9999); Wait(0.5); Type("{ENTER}",cpm:9999); // Making sure Salesforce logged into the authenticated user's landing page (Sales page) StartTimer(name:"UserLoggedInto"); StartTimer(name:"HomePageHomePaneLoaded"); var SalesforceMainWindow = FindWindow(title : "*Home | Salesforce*",timeout:60); // Looking for the "Home" tab / button SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[4]/Unknown[2]/Unknown[1]/List/ListItem/Hyperlink/Edit",timeout:60); StopTimer(name:"UserLoggedInto"); // Looking for Quarterly Performance string, found on the home page / home pane SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown[1]/Unknown/Unknown[1]/Unknown/Unknown/Edit",timeout:60); StopTimer(name:"HomePageHomePaneLoaded"); // Clicking on Opportunities tab var OpportunitiesTabButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[4]/Unknown[2]/Unknown[1]/List/ListItem[1]/Hyperlink",timeout:60); OpportunitiesTabButton.Click(); StartTimer(name:"OpportunitiesPageLoaded"); // Verifying the Opportunity Name column header / sorter is present SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown[1]/Unknown/Unknown[1]/Table/Unknown/Header[2]/Hyperlink",timeout:60); StopTimer(name:"OpportunitiesPageLoaded"); // Clicking on Leads tab / button var LeadsButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[4]/Unknown[2]/Unknown[1]/List/ListItem[2]/Hyperlink",timeout:60); LeadsButton.Click(); StartTimer(name:"LeadsPagePaneAppearTime"); // Waiting for the Name column header / sorter to appear SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown[1]/Unknown/Unknown[1]/Table/Unknown/Header[2]",timeout:60); StopTimer(name:"LeadsPagePaneAppearTime"); // Clicking on Accounts tab / button var AccountsTabButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[4]/Unknown[2]/Unknown[1]/List/ListItem[5]",timeout:60); AccountsTabButton.Click(); StartTimer(name:"AccountsPagePaneAppearTime"); // Waiting for the Account Name column header / sorter to appear SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown[1]/Unknown/Unknown[1]/Table/Unknown/Header[2]/Hyperlink",timeout:60); StopTimer(name:"AccountsPagePaneAppearTime"); // Clicking on Contacts tab / button var ContactsTabButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[4]/Unknown[2]/Unknown[1]/List/ListItem[6]/Hyperlink",timeout:60); ContactsTabButton.Click(); StartTimer(name:"ContactsPagePaneAppearTime"); // Waiting for the Contacts string to appear in the loaded pane SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown[1]/Unknown/Unknown/Unknown[1]/List/ListItem/Edit",timeout:60); StopTimer(name:"ContactsPagePaneAppearTime"); // Finding the Search Salesforce field and clicking on it var SearchSalesforceField = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[2]/ComboBox",timeout:60); SearchSalesforceField.Focus(); SearchSalesforceField.Click(); Wait(1); Type(SearchRecordQueryString,cpm:9999); Type("{enter}",cpm:9999); StartTimer(name:"NameSearchQueryLoadingTime"); // Waiting for the search result to appear, after the query is submitted var NameSearchQueryResult = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown[1]/Unknown/Unknown[2]/Unknown/Unknown/Unknown[2]/Table/Group/Unknown/Header/Hyperlink",timeout:60); StopTimer(name:"NameSearchQueryLoadingTime"); // Clicking on the result to load it NameSearchQueryResult.Click(); StartTimer(name:"NameSearchAfterClickLoadingTime"); // Looking for the "Manager" string / field SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown[1]/Unknown/Document/Unknown[1]/List/ListItem[1]/Unknown/Edit",timeout:60); StopTimer(name:"NameSearchAfterClickLoadingTime"); // Finding and clicking on the App Launcher button var AppLauncherButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[4]/Unknown/Unknown/Button",timeout:60); AppLauncherButton.Click(); StartTimer(name:"AppLauncherPageAppearTime"); // Waiting for the App Launcher page to load; looking for the "Search apps or items..." string / field SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown[1]/Unknown/Unknown[2]/Unknown/Edit",timeout:60); StopTimer(name:"AppLauncherPageAppearTime"); // Closing out of the App Launcher page var CloseAppLauncherPageButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown[1]/Button",timeout:60); CloseAppLauncherPageButton.Click(); Wait(2); // Logging out of user // Clicking on avatar button var AvatarButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown[3]/List/ListItem[7]/Unknown/Button",timeout:60); AvatarButton.Click(); // Clicking on Logout button var LogoutButton = SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown[1]/Unknown[2]/Hyperlink[1]",timeout:60); LogoutButton.Click(); // Waiting for the login page to appear again StartTimer(name:"TimeToLogUserOut"); // Looking for username field SalesforceMainWindow.FindControlWithXPath(xPath : "Group/Unknown/Unknown/Document/Unknown/Unknown/Unknown/Unknown/Unknown/Unknown[1]/Unknown/Unknown/Unknown/Unknown/Edit",timeout:60); StopTimer(name:"TimeToLogUserOut"); // Closing out of web browser, gracefully STOP(timeout:15); // Killing web browser if it doesn't close ShellExecute("cmd /c taskkill /f /im firef*",waitForProcessEnd:true,timeout:20); } }