using LoginPI.Engine.ScriptBase; using System.IO; public class concurrentlyRunningApps_LoginEnterpriseTestFiles : ScriptBase { private 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/K6ILGgQtHIo -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 showcase launching and interacting with multiple applications using files, which are download-able from the Login Enterprise virtual appliance, whilst keeping all of the applications launched. The workload will switch between the app that is in the "foreground" just as a real user would, but will keep several apps open concurrently, also just as a real user would. In order for this script to run ensure to have the following installed and activated: Excel, Microsft Edge, Word, Adobe Reader DC, and PowerPoint. Ensure Adobe Reader DC is the default .pdf file opener The following steps will be performed: -Copy down needed test files -Start the downloaded test files in the following apps with custom timer encapsulating the app starts: Excel, Word, Adobe Reader DC, Notepad, PowerPoint, Wordpad, and Microsft Edge -Bring each aforementioned app into focus sequentially, and when doing so scroll around the UI of each -Bring each aforementioned app into focus sequentially and maximizing the GUIs -Closing out of each app sequentially Developed with: -Scripting Toolset version Login Enterprise 4.4.9 -Last updated on 1 April 2021 -winver Windows 10 Pro x64 20H2 -Microsoft Office x64 365 desktop version 2101 (Build 13801.20360 Click-to-Run) -Adobe Acrobat Reader DC x86 version 2021.001.20145 -Microsoft Edge version 89.0.774.63 */ // Set global vars double globalIntermittentWaitInSeconds = 0.5; int globalFunctionTimeoutInSeconds = 30; int globalCharactersPerMinuteToType = 120; var temp = GetEnvironmentVariable("TEMP"); Log($"The environment path is: {temp}"); // Set registry paths to prevent Adobe and Office first-run-flows RegImport(create_regfile(@"HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\DC\FTEDialog",@"iFTEVersion",@"dword:00000010")); RegImport(create_regfile(@"HKEY_CURRENT_USER\Software\Adobe\\Acrobat Reader\DC\AVAlert\cCheckbox",@"iAppDoNotTakePDFOwnershipAtLaunchWin10",@"dword:00000001")); RegImport(create_regfile(@"HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\General",@"ShownFirstRunOptin",@"dword:00000001")); // Optional taskkills preliminarily ShellExecute(@"cmd /c taskkill /f /im excel.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); ShellExecute(@"cmd /c taskkill /f /im msedge.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); ShellExecute(@"cmd /c taskkill /f /im narrator.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); ShellExecute(@"cmd /c taskkill /f /im winword.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); ShellExecute(@"cmd /c taskkill /f /im acrord32.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); ShellExecute(@"cmd /c taskkill /f /im notepad.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); ShellExecute(@"cmd /c taskkill /f /im powerpnt.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); ShellExecute(@"cmd /c taskkill /f /im wordpad.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); // Downloading the files from the Login Enterprise virtual appliance that will be needed in this workload script; setting up files CopyFile(KnownFiles.ExcelSheet,$"{temp}\\LoginPI\\LoginEnterpriseExcelSheet.xlsx",overwrite:true); CopyFile(KnownFiles.WordDocument,$"{temp}\\LoginPI\\LoginEnterpriseWordDocument.docx",overwrite:true); CopyFile(KnownFiles.PdfFile,$"{temp}\\LoginPI\\LoginEnterprisePdfFile.pdf",overwrite:true); CopyFile(KnownFiles.PlainTextFile,$"{temp}\\LoginPI\\LoginEnterprisePlainTextFile.txt",overwrite:true); CopyFile(KnownFiles.PowerPointPresentation,$"{temp}\\LoginPI\\LoginEnterprisePowerPointPresentation.pptx",overwrite:true); CopyFile(KnownFiles.RichTextFile,$"{temp}\\LoginPI\\LoginEnterpriseRichTextFile.rtf",overwrite:true); CopyFile(KnownFiles.WebSite,$"{temp}\\LoginPI\\vsiwebsite.zip",overwrite:true); try { UnzipFile($"{temp}\\LoginPI\\vsiwebsite.zip", $"{temp}\\LoginPI\\vsiwebsite",overWrite:true); // Extracting the downloaded sample website Log(@"Unzipped website successfully"); } catch { Log(@"Unzipped website already exists. Assuming it exists in totality..."); } // This will launch the defined apps with the sample test files StartTimer("AdobeReaderStartTime"); START(timeout:globalFunctionTimeoutInSeconds, forceKillOnExit:true,mainWindowClass:"Win32 Window:AcrobatSDIWindow",mainWindowTitle:"*Adobe Acrobat Reader DC*",processName:"AcroRd32"); MainWindow.FindControlWithXPath(xPath : "Pane:AVL_AVView",timeout:globalFunctionTimeoutInSeconds); // This will find the main Adobe Reader DC document pane StopTimer("AdobeReaderStartTime"); StartTimer("ExcelStartTime"); ShellExecute($"{temp}\\LoginPI\\LoginEnterpriseExcelSheet.xlsx",waitForProcessEnd:false); var excelWindow = FindWindow(className : "Win32 Window:XLMAIN", title : "LoginEnterpriseExcelSheet* - Excel", processName : "EXCEL",timeout:globalFunctionTimeoutInSeconds); excelWindow.FindControlWithXPath(xPath : "Pane:XLDESK",timeout:globalFunctionTimeoutInSeconds); // This finds the main Excel pane StopTimer("ExcelStartTime"); StartTimer("WordStartTime"); ShellExecute($"{temp}\\LoginPI\\LoginEnterpriseWordDocument.docx",waitForProcessEnd:false); var wordWindow = FindWindow(className : "Win32 Window:OpusApp", title : "LoginEnterpriseWordDocument* - Word", processName : "WINWORD",timeout:globalFunctionTimeoutInSeconds); wordWindow.FindControlWithXPath(xPath : "Pane:_WwF",timeout:globalFunctionTimeoutInSeconds); // This will find the main text editor frame StopTimer("WordStartTime"); StartTimer("NotepadStartTime"); ShellExecute("notepad " + $"{temp}\\LoginPI\\LoginEnterprisePlainTextFile.txt",waitForProcessEnd:false); var notepadWindow = FindWindow(className : "Win32 Window:Notepad", title : "LoginEnterprisePlainTextFile* - Notepad", processName : "notepad",timeout:globalFunctionTimeoutInSeconds); notepadWindow.FindControlWithXPath(xPath : "Document:Edit",timeout:globalFunctionTimeoutInSeconds); // This will find the main text editor pane StopTimer("NotepadStartTime"); StartTimer("PowerPointStartTime"); ShellExecute($"{temp}\\LoginPI\\LoginEnterprisePowerPointPresentation.pptx",waitForProcessEnd:false); var powerPointWindow = FindWindow(className : "Win32 Window:PPTFrameClass", title : "LoginEnterprisePowerPointPresentation* - PowerPoint", processName : "POWERPNT",timeout:globalFunctionTimeoutInSeconds); powerPointWindow.FindControlWithXPath(xPath : "Pane:MDIClient",timeout:globalFunctionTimeoutInSeconds); // This will find the main PowerPoint loaded file pane StopTimer("PowerPointStartTime"); StartTimer("WordpadStartTime"); ShellExecute("wordpad " + $"{temp}\\LoginPI\\LoginEnterpriseRichTextFile.rtf",waitForProcessEnd:false); var wordpadWindow = FindWindow(className : "Win32 Window:WordPadClass", title : "LoginEnterpriseRichTextFile* - WordPad", processName : "wordpad",timeout:globalFunctionTimeoutInSeconds); wordpadWindow.FindControlWithXPath(xPath : "Document:RICHEDIT50W",timeout:globalFunctionTimeoutInSeconds); // This will find the main text editor pane StopTimer("WordpadStartTime"); ShellExecute("narrator",waitForProcessEnd:false,forceKillOnExit:true); // This will start the built-in Windows Narrator to enable msedge exposing "win32" objects StartTimer("MicrosoftEdgeStartTime"); ShellExecute("msedge " + $"{temp}\\LoginPI\\vsiwebsite\\ChromeScript\\videopage.html",waitForProcessEnd:false); var microsoftEdgeWindow = FindWindow(className : "Win32 Window:Chrome_WidgetWin_1", title : "Video Page *", processName : "msedge",timeout:globalFunctionTimeoutInSeconds); microsoftEdgeWindow.FindControlWithXPath(xPath : "Pane:BrowserRootView",timeout:globalFunctionTimeoutInSeconds); // This makes sure the main webpage viewer pane has loaded in Microsoft Edge StopTimer("MicrosoftEdgeStartTime"); ShellExecute(@"taskkill /f /im narrator.ex*",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true); Wait(globalIntermittentWaitInSeconds); // This will bring each file/applications' window into focus sequentially, and navigate around in it excelWindow.Focus(); Wait(globalIntermittentWaitInSeconds); excelWindow.Type("{pagedown}{pagedown}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); excelWindow.Type("{pageup}{pageup}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); wordWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordWindow.Type("{pagedown}{pagedown}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); wordWindow.Type("{pageup}{pageup}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); MainWindow.Focus(); Wait(globalIntermittentWaitInSeconds); MainWindow.Type("{ctrl+o}"); var MainWindowOpenDialog = FindWindow(title : "Open", processName : "AcroRd32",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); MainWindowOpenDialog.Focus(); MainWindowOpenDialog.Type("{alt+n}" + $"{temp}\\LoginPI\\LoginEnterprisePdfFile.pdf" + "{enter}",cpm:1500); var MainWindowFileLoadedWindow = FindWindow(className : "Win32 Window:AcrobatSDIWindow", title : "*LoginEnterprisePdfFile* - Adobe Acrobat Reader DC*", processName : "AcroRd32"); Wait(globalIntermittentWaitInSeconds); MainWindowFileLoadedWindow.Type("{pagedown}{pagedown}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); MainWindowFileLoadedWindow.Type("{pageup}{pageup}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); notepadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); notepadWindow.Type("{pagedown}{pagedown}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); notepadWindow.Type("{pageup}{pageup}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); powerPointWindow.Focus(); Wait(globalIntermittentWaitInSeconds); powerPointWindow.Type("{pagedown}{pagedown}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); powerPointWindow.Type("{pageup}{pageup}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Type("{pagedown}{pagedown}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Type("{pageup}{pageup}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); microsoftEdgeWindow.Focus(); Wait(globalIntermittentWaitInSeconds); microsoftEdgeWindow.Type("{pagedown}{pagedown}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); microsoftEdgeWindow.Type("{pageup}{pageup}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); // This will bring each file/applications' window into focus sequentially, and maximize the window excelWindow.Focus(); Wait(globalIntermittentWaitInSeconds); excelWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); wordWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); MainWindowFileLoadedWindow.Focus(); Wait(globalIntermittentWaitInSeconds); MainWindowFileLoadedWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); notepadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); notepadWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); powerPointWindow.Focus(); Wait(globalIntermittentWaitInSeconds); powerPointWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); microsoftEdgeWindow.Focus(); Wait(globalIntermittentWaitInSeconds); microsoftEdgeWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); // This will close each of the open file/applications' windows sequentially excelWindow.Focus(); Wait(globalIntermittentWaitInSeconds); excelWindow.Close(); wordWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordWindow.Close(); MainWindowFileLoadedWindow.Focus(); Wait(globalIntermittentWaitInSeconds); MainWindowFileLoadedWindow.Close(); notepadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); notepadWindow.Close(); powerPointWindow.Focus(); Wait(globalIntermittentWaitInSeconds); powerPointWindow.Close(); wordpadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Close(); microsoftEdgeWindow.Focus(); Wait(globalIntermittentWaitInSeconds); microsoftEdgeWindow.Close(); try { STOP(timeout:1); } catch {} } private string create_regfile(string key, string value, string data) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); var file = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "reg.reg"); sb.AppendLine("Windows Registry Editor Version 5.00"); sb.AppendLine(); sb.AppendLine($"[{key}]"); if(data.ToLower().Contains("dword")) { sb.AppendLine($"\"{value}\"={data.ToLower()}"); } else { sb.AppendLine($"\"{value}\"=\"{data}\""); } sb.AppendLine(); System.IO.File.WriteAllText(file, sb.ToString()); return file; } }