using LoginPI.Engine.ScriptBase; using System; public class SAP_Web : 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. -YouTube video: https://youtu.be/Fr_K5emXHT8 -Run the workload against the "target" using Script Editor to ensure it will work before uploading it and testing with it -If needed, configure the Set global variables section of this workload -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 -Leave Application running compatibility: false This workload will: -Start the web browser -Navigate to the defined SAP URL enter the login credentials -Click on the login button and measure login time -Create a new customerproject: --Click the "Plan Customer Projects" tile --Fill out the customer details --Fill out the account details --Click on save -Go back to Customer Projects page -Delete the project -Close out of the web browser */ // set variables here int globalTimeoutInSeconds = 30; // Define here how long to wait in seconds for a function to complete, before timing out int uiCatchupWaitCadenceInSeconds = 5; // Define here how long to wait in seconds in between functions being performed. This is to allow the UI of the SAP app to catch-up string sapURL = @"https://mysapurl.com"; // Define the SAP URL to navigate to here // Define the pool of projects here, the list: string[] projects = {"Morning Silly", "Skilled Emerald", "Furious Sunshine", "Doorstop Harsh", "Digital Aggressive Python", "Toupee Flaming", "Third Square Pottery", "Hungry Oyster", "Big Scissors", "Third Finger", "Dreadful Poseidon", "Freaky Mercury", "Lucky Sapphire", "Harsh Alarm", "Nocturnal Foot", "Timely Eastern Moon", "Full Mountain", "Strong Antique", "Epsilon Elastic", "Scorpion Intensive", "Disappointed Backpack", "Olive Eastern Hammer", "Moving Dreadful Avenue"}; Random rand = new Random(); // end set variables // This will start the web browser StartBrowser(timeout:globalTimeoutInSeconds); // This will navigate to the defined SAP URL Navigate(sapURL); StartTimer("BrowseToURL"); FindWebComponentBySelector("input[id='j_username']", timeout:globalTimeoutInSeconds); // This will look for the username field StopTimer("BrowseToURL"); MainWindow.Maximize(); // This will enter the login credentials Wait(uiCatchupWaitCadenceInSeconds, true, "Entering login credentials"); FindWebComponentBySelector("input[id='j_username']",timeout:globalTimeoutInSeconds).Type(ApplicationUser); // This will type in the defined username FindWebComponentBySelector("input[id='j_password']",timeout:globalTimeoutInSeconds).Type(ApplicationPassword); // This will type in the defined password Wait(uiCatchupWaitCadenceInSeconds); // This will click on the login button and measure login time FindWebComponentBySelector("button[id='logOnFormSubmit']",timeout:globalTimeoutInSeconds).Click(); StartTimer("Login_Time"); FindWebComponentBySelector("div[id='shell-header-hdr-search-container']",timeout:globalTimeoutInSeconds); StopTimer("Login_Time"); // Workflow to create customer project... // This will click the "Plan Customer Projects" tile Wait(uiCatchupWaitCadenceInSeconds, true, "Starting the Create Customer Project workflow"); FindWebComponentBySelector("span[id='__tile2-title-inner']",timeout:globalTimeoutInSeconds).Click(); StartTimer("Load_Customer_Projects_Page"); FindWebComponentBySelector("span[id='application-CustomerProject-maintainCustomerProject-component---detail--page-title-inner']",timeout:globalTimeoutInSeconds); StopTimer("Load_Customer_Projects_Page"); // This will create a new project Wait(uiCatchupWaitCadenceInSeconds, true, "Creating a new project"); FindWebComponentBySelector("span[id='__action2-button-img']",timeout:globalTimeoutInSeconds).Click(); StartTimer("Load_New_Projects_Page"); FindWebComponentBySelector("h5[id='Create--CustomerProject--title']",timeout:globalTimeoutInSeconds); StopTimer("Load_New_Projects_Page"); // This will fill out the customer details Wait(uiCatchupWaitCadenceInSeconds, true, "Filling out customer details"); FindWebComponentBySelector("span[id='Create--cust-vhi']",timeout:globalTimeoutInSeconds).Click(); Wait(uiCatchupWaitCadenceInSeconds); var company = FindWebComponentBySelector("#__dialog0-table-rows-row"+rand.Next(0, 9)+"-col1",timeout:globalTimeoutInSeconds, true); if(company != null) { company.Click(); } else { FindWebComponentBySelector("#__dialog0-table-rows-row"+rand.Next(0, 9)+"-col1",timeout:globalTimeoutInSeconds).Click(); } Wait(uiCatchupWaitCadenceInSeconds); FindWebComponentBySelector("input[id='Create--ProjID-inner']",timeout:globalTimeoutInSeconds).Type(rand.Next(999999999).ToString()); Wait(uiCatchupWaitCadenceInSeconds); FindWebComponentBySelector("input[id='Create--ProjName-inner']",timeout:globalTimeoutInSeconds).Type(projects[rand.Next(projects.Length)]); Wait(uiCatchupWaitCadenceInSeconds); // This will fill out the account details FindWebComponentBySelector("#Create--CCId-arrow",timeout:globalTimeoutInSeconds).Click(); Wait(uiCatchupWaitCadenceInSeconds); FindWebComponentBySelector("#Create--CCId-valueStateText li:nth-of-type("+rand.Next(2,4)+")",timeout:globalTimeoutInSeconds).Click(); Wait(uiCatchupWaitCadenceInSeconds); FindWebComponentBySelector("span[id='Create--CPM_PROFIT_CENTER-arrow']",timeout:globalTimeoutInSeconds).Click(); Wait(uiCatchupWaitCadenceInSeconds); FindWebComponentBySelector("#Create--CPM_PROFIT_CENTER-valueStateText li:nth-of-type("+rand.Next(2,13)+")",timeout:globalTimeoutInSeconds).Click(); Wait(uiCatchupWaitCadenceInSeconds); // This will click save, and proceed Wait(uiCatchupWaitCadenceInSeconds, true, "Saving the project"); FindWebComponentBySelector("bdi[id='application-CustomerProject-maintainCustomerProject-component---create--CPM_CUST_PROJ_PROCEED-button-BDI-content']",timeout:globalTimeoutInSeconds).Click(); StartTimer("Save_Project"); FindWebComponentBySelector("div[class='sapMMessageToast sapUiSelectable sapContrast sapContrastPlus']",timeout:globalTimeoutInSeconds); StopTimer("Save_Project"); Wait(uiCatchupWaitCadenceInSeconds, true, "Project saved"); // This will go back to Customer Projects page Wait(uiCatchupWaitCadenceInSeconds); MainWindow.FindControl(className : "Button", title : "Back",timeout:globalTimeoutInSeconds).Click(); Wait(uiCatchupWaitCadenceInSeconds); // This will delete the project Wait(uiCatchupWaitCadenceInSeconds, true, "Deleting the project"); FindWebComponentBySelector("bdi[id='__action1-button-BDI-content']",timeout:globalTimeoutInSeconds).Click(); Wait(uiCatchupWaitCadenceInSeconds); FindWebComponentBySelector("bdi[id='__mbox-btn-0-BDI-content']",timeout:globalTimeoutInSeconds).Click(); StartTimer("Delete_Project"); FindWebComponentBySelector("div[class='sapMMessageToast sapUiSelectable sapContrast sapContrastPlus']",timeout:globalTimeoutInSeconds); StopTimer("Delete_Project"); Wait(uiCatchupWaitCadenceInSeconds, true, "Project deleted"); // This will close out of the web browser Wait(uiCatchupWaitCadenceInSeconds); StopBrowser(); } }