using LoginPI.Engine.ScriptBase; using System; using System.Runtime.InteropServices; public class Chrome : ScriptBase { void Execute() { // Start and focus the application START(); MainWindow.Focus(); Wait(1); // Select address bar with hotkey and type google.com MainWindow.Type("{ctrl+l}"); Wait(1); MainWindow.Type("google.com{enter}"); Wait(1); // Perform a google search "login vsi pi" MainWindow.FindControl(className:"Document:Chrome_RenderWidgetHostHWND", title:"Chrome Legacy Window", timeout:30).FindControl(className:"ComboBox", title:"Search").Type("login vsi pi{esc}"); Wait(1); MainWindow.FindControl(className : "Button", title : "Google Search*").Click(); Wait(1); // Find browser tab with the text "login vsi pi" MainWindow.FindControl(className : "TabItem", title : "*login vsi pi*", timeout:10); Wait(1); // Scroll through results page Scroll(10, 15, 14, 2, 100, 100); Wait(1); // Click on result with title "Login PI: Real-World Performance Insights" MainWindow.FindControl(title : "Login PI: Real-World Performance Insights*").MoveMouseToCenter(); MainWindow.FindControl(title : "Login PI: Real-World Performance Insights*").Click(); Wait(1); // Find browser tab with the text "Login PI: Real-World Performance Insights*" MainWindow.FindControl(className : "TabItem", title : "Login PI: Real-World Performance Insights*", timeout:10); Wait(3); // Scroll through the web page Scroll(15, 18, 3, 2, 150, 150); Wait(5); } void Scroll(int time, int downamount, int upamount, double downupwait, int downcpm, int upcpm) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var startTime = DateTime.UtcNow; while (startTime.AddSeconds(time) > DateTime.UtcNow) { Wait(downupwait); MainWindow.Type("{down}".Repeat(downamount), downcpm); Wait(downupwait); MainWindow.Type("{up}".Repeat(upamount), upcpm); } } } }