using LoginPI.Engine.ScriptBase; using System.Diagnostics; public class SkypeForBusiness : 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 -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 -This workload will: send a Skype chat message to a contact. It will: Check to see if Skype (lync.exe) is running and start the application if it isn't Click on the contacts button and look up a contact by name Open a chat window with the contact and send a test message Verify that the test message was typed correctly (no missed keystrokes) Close the chat window -Workload version and changelist: --V1.0 | original -Leave Application running compatibility: true */ // Define script variables // Name of person to search in Skype string recipientName = "Josh Kennedy"; // Test message to send to recipient string testMessage = "Hello! This is a test message."; // Set to true if sign in is required bool signInRequired = false; // Check for the Skype process and and start Skype if it's not already running Process[] processes = Process.GetProcessesByName("lync"); if (processes.Length < 1) { START(); Wait(2); } // Set Skype mainWindow variable and focus Skype window var mainWindow = FindWindow(title:"Skype for Business*", className:"Win32 Window:CommunicatorMainWindowClass", timeout:30 , continueOnError:true); Wait(0.5); mainWindow.Focus(); // Handle sign in if signInRequired is true if (signInRequired == true) { // Check to see if sign in button exist and click it if (mainWindow.FindControl(className:"Button:NetUIButton", title:"Sign In", timeout:3, continueOnError:true) != null) { // Place logic to authenticate with credentials here if required // mainWindow.FindControl(className:"Button:NetUIButton", title:"Sign In").Click(); Wait(5); } } Wait(0.5); // Create variable for Contacts button and click it var contactsBtn = mainWindow.FindControl(className: "ListItem:NetUIGalleryButton", title:"Contacts", timeout:15); Wait(0.5); contactsBtn.Click(); Wait(0.5); // Search for Skype user by typing into the search box and press enter to open a chat box mainWindow.FindControl(className:"Edit:NetUITextbox", title:"Search Input").Type(recipientName+"{enter}"); Wait(1); mainWindow.FindControl(className:"Text:NetUILabel", title:recipientName, timeout:10); Wait(1); mainWindow.FindControl(className:"Edit:NetUITextbox", title:"Search Input").Type("{enter}"); StartTimer(name:"Open_Chat_Window_Timer"); // Find chat window and send test message var skypeIMWindow = FindWindow(recipientName, className:"Win32 Window:LyncTabFrameHostWindowClass", processName:"lync", timeout:15); StopTimer(name:"Open_Chat_Window_Timer"); Wait(0.5); skypeIMWindow.FindControl(className:"Edit:NetUIRicherTextbox", title:"Chat Input. Conversation with "+recipientName).Type(testMessage+"{enter}"); StartTimer(name:"Send_Chat_Message_Timer"); // Try catch logic to confirm that message has been sent and text matches try { skypeIMWindow.FindControl(className:"ListItem:NetUIListViewItem", title:"*"+testMessage+"*"); StopTimer(name:"Send_Chat_Message_Timer"); Wait(0.5); skypeIMWindow.FindControl(className:"Edit:NetUIRicherTextbox", title:"Chat Input. Conversation with*").Type("Test message was successful!{enter}"); Wait(0.5); skypeIMWindow.FindControl(className : "Button:NetUIAppFrameHelper", title : "Close").Click(); } catch { Log("Send message failed"); CancelTimer(name:"Send_Chat_Message_Timer"); skypeIMWindow.FindControl(className:"Edit:NetUIRicherTextbox", title:"Chat Input. Conversation with*").Type("Test message did not match, maybe a missed keystroke?{enter}"); Wait(5, true, "Closing window in 5 seconds..."); skypeIMWindow.FindControl(className : "Button:NetUIAppFrameHelper", title : "Close").Click(); } Wait(1); } }