private void ProfilesImExSwitch(ATElementStruct whichProfile, AT profileTmp, AT loadingTmp, string whereToClick, bool isAimpad = false)
 {
     profileTmp = SwMainWindow.GetElement(whichProfile);
     profileTmp.DoClickPoint();
     WaitForEvent(profileTmp, loadingTmp, isAimpad);
     profileTmp = SwMainWindow.GetElement(whichProfile);
     if (whereToClick.Equals("EXPORT"))
     {
         profileTmp.GetElement(PortalObj.Profile_EXPORT).DoClickPoint();
         var dialog     = SwMainWindow.GetElement(PortalObj.Window_OpenFIle, treeScope: ATElement.TreeScope.Children, timeout: 5);
         var buttonSave = dialog.GetElement(PortalObj.Button_Save, treeScope: ATElement.TreeScope.Children, timeout: 1);
         buttonSave.DoClickPoint();
         try
         {
             dialog.GetElement(aTElementStruct: PortalObj.Button_Exist_Yes, treeScope: ATElement.TreeScope.Descendants, timeout: 1).DoClickPoint();
         }
         catch (Exception)
         {
             // ignored
         }
         WaitForEvent(profileTmp, loadingTmp, isAimpad);
     }
     else if (whereToClick.Equals("IMPORT"))
     {
         profileTmp.GetElement(PortalObj.Profile_IMPORT).DoClickPoint();
         var dialog = SwMainWindow.GetElement(PortalObj.Window_OpenFIle, treeScope: ATElement.TreeScope.Children, timeout: 5);
         dialog = dialog.GetElement(PortalObj.Button_Save, treeScope: ATElement.TreeScope.Children, timeout: 1);
         dialog.DoClickPoint();
         WaitForEvent(profileTmp, loadingTmp, isAimpad);
     }
 }
        public void Flow_Installation(string buildPath, bool checkRemove = true, string language = "English")
        {
            UtilProcess.KillProcessByFuzzyName("MasterPlus");
            UtilTime.WaitTime(1);
            var uninstallerPath = UtilRegistry.GetProductInfo("MasterPlus(PER. Only).*", UtilRegistry.ProductInfo.UninstallString);

            if (!uninstallerPath.Equals(string.Empty))
            {
                WriteConsoleTitle(LaunchTimes, $"Waiting for silent uninstalling. ({2}s)", 2);
                UtilProcess.StartProcessGetString(uninstallerPath, "/silent");
                UtilTime.WaitTime(1);
            }
            UtilProcess.StartProcess(buildPath);
            AT Window_SelectLauguage = new AT().GetElement(PortalObj.Window_SelectLauguage, Timeout = 5, treeScope: AT.TreeScope.Children);

            AT ComboBox_SelectLauguage = Window_SelectLauguage.GetElement(PortalObj.ComboBox_SelectLauguage);

            ComboBox_SelectLauguage.DoExpand();
            Window_SelectLauguage = new AT().GetElement(PortalObj.Window_SelectLauguage, Timeout = 5, treeScope: AT.TreeScope.Children); //refresh
            Window_SelectLauguage.GetElement(name: language, treeScope: AT.TreeScope.Descendants).DoSelect(1);
            AT Button_OK = Window_SelectLauguage.GetElement(PortalObj.Button_Install_OK, Timeout = 2);

            Button_OK.DoClick(1);
            AT Window_InstallWizard = new AT().GetElement(PortalObj.Window_InstallWizard, Timeout = 5, treeScope: AT.TreeScope.Children);

            UtilTime.WaitTime(1);
            AT Button_RemoveCache = Window_InstallWizard.GetElement(PortalObj.CheckBox_RemoveCache, Timeout = 2);

            Button_RemoveCache.DoClickPoint(waitTime: 1);
            AT Button_Next = Window_InstallWizard.GetElement(PortalObj.Button_Next);

            Button_Next.DoClick(1);
            AT Button_Location_Next = Window_InstallWizard.GetElement(PortalObj.Button_Location_Next);

            Button_Location_Next.DoClick(2);
            try
            {
                AT Dialog_FolderExists           = Window_InstallWizard.GetElement(PortalObj.Dialog_FolderExists);
                AT Button_DialogFolderExists_Yes = Dialog_FolderExists.GetElement(PortalObj.Button_DialogFolderExists_Yes);
                Button_DialogFolderExists_Yes.DoClick(1);
            }
            catch (Exception)
            {
            }
            AT Button_SelectStartMemuFolder_Next = Window_InstallWizard.GetElement(PortalObj.Button_SelectStartMemuFolder_Next);

            Button_SelectStartMemuFolder_Next.DoClick(1);
            AT Button_AddtionalTask_Next = Window_InstallWizard.GetElement(PortalObj.Button_AddtionalTask_Next);

            Button_AddtionalTask_Next.DoClick(1);
            AT Button_ReadyToInstall_Install = Window_InstallWizard.GetElement(PortalObj.Button_ReadyToInstall_Install);

            Button_ReadyToInstall_Install.DoClick(1);
            AT CheckBox_LaunchPortal = Window_InstallWizard.GetElement(PortalObj.CheckBox_LaunchPortal, Timeout = 20);
            AT Button_Finish         = Window_InstallWizard.GetElement(PortalObj.Button_Finish);

            Button_Finish.DoClick(1);
            AT Window_MasterPlusPer = new AT().GetElement(PortalObj.Window_MasterPlusPer, timeout: 10);
        }
        public void LaunchAndCheckCrash(long testTimes)
        {
            var crashTimes = 0;

            UtilCmd.Clear();
            for (var i = 1; i < testTimes; i++)
            {
                var titleTotal = $"Reopen Times: {i} - Crash Times: {crashTimes}";
                var logLines   = UtilFile.ReadFileByLine(LogPathLaunch);
                logLines.ForEach(UtilCmd.WriteLine);
                //logLines.ForEach(line => UtilCmd.WriteLine(line));
                var launchLogTime  = GetRestartLogTime();
                var screenshotPath = Path.Combine(ScreenshotsPath, crashTimes.ToString());
                UtilProcess.StartProcess(SwLnkPath);
                Timeout = 1;
                UtilCmd.WriteTitle($"{titleTotal} - Searching MP+ UI.");
                var startTime     = DateTime.Now;
                var dialogWarning = UtilWait.ForAnyResultCatch(() =>
                {
                    UtilCmd.WriteTitle($"{titleTotal} - Searching Warning dialog of the MP+ in 60s. Time elapsed: {(DateTime.Now - startTime).Seconds}s.");
                    SwMainWindow = new AT().GetElement(MPObj.MainWindow, Timeout);  // The MP+ will change after a while.
                    return(SwMainWindow.GetElement(MPObj.DialogWarning, Timeout));
                }, 60, 2);
                if (SwMainWindow == null)
                {
                    UtilCapturer.Capture(i.ToString());
                    UtilFile.WriteFile(LogPathLaunch, $"{launchLogTime}: Reopen Times: {i} - Could not open MasterPlus.");
                    crashTimes++;
                }
                UtilTime.WaitTime(1);
                UtilProcess.KillProcessByName(SwProcessName);
                UtilTime.WaitTime(1);
            }
        }
Beispiel #4
0
        private void Form_Main_Load(object sender, EventArgs e)
        {
            AT aa = new AT();

            aa = aa.GetElement(Name: "Program Manager");
            Console.ReadKey();
        }
Beispiel #5
0
        private void OpenRemovableDevices(AT windowVm)
        {
            var tabTestVm = windowVm.GetElement(VmObj.Tab_TestVM);

            tabTestVm.DoSetFocus();
            UtilTime.WaitTime(1);
            tabTestVm.DoClickPoint(10, 10, mk: HWSimulator.HWSend.MouseKeys.RIGHT);
            UtilTime.WaitTime(0.5);
            var itemRemovableDevices = new AT().GetElement(VmObj.Item_RemovableDevices);

            itemRemovableDevices.DoClickPoint(mk: HWSimulator.HWSend.MouseKeys.NOTCLICK);
            UtilTime.WaitTime(0.5);
        }
        public void SelectTestDevice(string deviceName, AT swMainWindow)
        {
            var deviceList = swMainWindow.GetElement(MPObj.DeviceList);
            //var devices = deviceList.GetElementsAllChild();
            //return devices.GetElementByIA(new ATElementStruct() { IADescription = deviceName });
            var dut = deviceList.GetElementFromChild(new ATElementStruct()
            {
                Name = deviceName
            });

            //dut.DoClickPoint(waitTime: 1);
            dut.DoClick(2);
        }
Beispiel #7
0
 private AT GetInvokerElementByPropertyType(AT parent, string propertyType, string propertyValue, string controlTypeValue)
 {
     if (propertyType.Equals(StructPropertyType.index))
     {
         return(parent.GetElement(treeScope: ATElement.TreeScope.Descendants, index: int.Parse(propertyValue), controlType: controlTypeValue));
     }
     else if (propertyType.Equals(StructPropertyType.name))
     {
         return(parent.GetElement(treeScope: ATElement.TreeScope.Descendants, name: propertyValue, controlType: controlTypeValue));
     }
     else if (propertyType.Equals(StructPropertyType.className))
     {
         return(parent.GetElement(treeScope: ATElement.TreeScope.Descendants, className: propertyValue, controlType: controlTypeValue));
     }
     else if (propertyType.Equals(StructPropertyType.id))
     {
         return(parent.GetElement(automationId: propertyValue, controlType: controlTypeValue));
     }
     else if (propertyType.Equals(StructPropertyType.hwnd))
     {
         return(parent.GetElementFromHwnd(new IntPtr(Convert.ToInt32(propertyValue))));
     }
     return(null);
 }
        public void RestartSystemAndCheckDeviceRecognitionFlow(XmlOps xmlOps)
        {
            UtilFolder.CreateDirectory(Path.Combine(ScreenshotsPath, "Restart"));
            var restartLogTime = GetRestartLogTime();
            var screenshotPath = Path.Combine(RestartScreenshotPath, restartLogTime);
            var logLines       = UtilFile.ReadFileByLine(LogPathRestart);

            logLines.ForEach(line => UtilCmd.WriteLine(line));
            var titleLaunchTimes = xmlOps.GetRestartTimes();
            var titleTotal       = $"Restart Times: {titleLaunchTimes} - Error Times: {logLines.Count}";
            var t = UtilWait.WaitTimeElapseThread($"{titleTotal} - Waiting 35s.", 35);

            t.Start();
            t.Join();
            if (!File.Exists(SwLnkPath))
            {
                UtilCmd.WriteTitle($"{titleTotal} - Could not find {SwLnkPath}.");
                UtilCmd.PressAnyContinue();
            }
            UtilProcess.StartProcess(SwLnkPath);
            Timeout = 1;
            UtilCmd.WriteTitle($"{titleTotal} - Searching MP+ UI.");
            var startTime     = DateTime.Now;
            var dialogWarning = UtilWait.ForAnyResultCatch(() =>
            {
                UtilCmd.WriteTitle($"{titleTotal} - Searching Warning dialog of the MP+ in 60s. Time elapsed: {(DateTime.Now - startTime).Seconds}s.");
                SwMainWindow = new AT().GetElement(MPObj.MainWindow, Timeout);  // The MP+ will change after a while.
                return(SwMainWindow.GetElement(MPObj.DialogWarning, Timeout));
            }, 60, 3);

            if (SwMainWindow == null)
            {
                //UtilCmd.WriteTitle($"Restart Times: {titleLaunchTimes} - Could not open MasterPlus.");
                UtilCapturer.Capture(screenshotPath);
                UtilFile.WriteFile(LogPathRestart, $"{restartLogTime}: Restart Times: {titleLaunchTimes} - Could not open MasterPlus.");
            }
            else if (dialogWarning != null)
            {
                UtilCapturer.Capture(screenshotPath);
                //UtilCmd.WriteTitle($"Restart Times: {titleLaunchTimes} - The device was not displayed");
                UtilFile.WriteFile(LogPathRestart, $"{restartLogTime}: Restart Times: {titleLaunchTimes} - The device was not displayed.");
            }
            xmlOps.SetRestartTimes(Convert.ToInt16(titleLaunchTimes) + 1);
            UtilTime.WaitTime(1);
            UtilProcess.KillProcessByName(this.SwProcessName);
            //UtilProcess.ExecuteCmd();// sometimes it does not work somehow.
            UtilOS.Reboot();
        }