Exemplo n.º 1
0
        /// <summary>
        /// RecordedMethod1 - Use 'RecordedMethod1Params' to pass parameters into this method.
        /// </summary>
        public void RecordedMethod1()
        {
            #region Variable Declarations
            WinListItem    uIFileAnalyzerShortcutListItem = this.UIProgramManagerWindow.UIDesktopList.UIFileAnalyzerShortcutListItem;
            WinMenuItem    uIOpenMenuItem     = this.UIFileAnalyzerWindow.UIMenuBarMenuBar.UIFileMenuItem.UIOpenMenuItem;
            WinEdit        uINameEdit         = this.UIOpenWindow.UIItemWindow.UITwoCitiesListItem.UINameEdit;
            WinSplitButton uIOpenSplitButton  = this.UIOpenWindow.UIOpenWindow1.UIOpenSplitButton;
            WinEdit        uISubstringBoxEdit = this.UIFileAnalyzerWindow.UISubstringBoxWindow.UISubstringBoxEdit;
            WinButton      uICountButton      = this.UIFileAnalyzerWindow.UICountWindow.UICountButton;
            #endregion

            // Double-Click 'FileAnalyzer - Shortcut' list item
            Mouse.DoubleClick(uIFileAnalyzerShortcutListItem, new Point(53, 33));

            // Double-Click 'FileAnalyzer - Shortcut' list item
            Mouse.DoubleClick(uIFileAnalyzerShortcutListItem, new Point(40, 27));

            // Launch '%USERPROFILE%\Source\CS 3500 S16\examples\FileAnalyzer\FileAnalyzer5\bin\Debug\FileAnalyzer.exe'
            ApplicationUnderTest uIFileAnalyzerWindow = ApplicationUnderTest.Launch(this.RecordedMethod1Params.UIFileAnalyzerWindowExePath, this.RecordedMethod1Params.UIFileAnalyzerWindowAlternateExePath);

            // Click 'File' -> 'Open ...' menu item
            Mouse.Click(uIOpenMenuItem, new Point(53, 11));

            // Click 'Name' text box
            Mouse.Click(uINameEdit, new Point(43, 18));

            // Click '&Open' split button
            Mouse.Click(uIOpenSplitButton, new Point(41, 15));

            // Type 'the' in 'substringBox' text box
            uISubstringBoxEdit.Text = this.RecordedMethod1Params.UISubstringBoxEditText;

            // Click 'Count' button
            Mouse.Click(uICountButton, new Point(32, 12));
        }
Exemplo n.º 2
0
        /// <summary>
        /// RecordedMethod4 - Verwenden Sie "RecordedMethod4Params", um Parameter an diese Methode zu übergeben.
        /// </summary>
        public void RecordedMethod4()
        {
            #region Variable Declarations
            WinClient      uITransportAppClient           = this.UITransportAppWindow.UITransportAppClient;
            WinButton      uIVerbindungsuchenButton       = this.UITransportAppWindow.UIVerbindungsuchenWindow.UIVerbindungsuchenButton;
            WinSplitButton uIÄnderungsdatumSplitButton    = this.UIDebugWindow.UIItemWindow.UIKopfzeileList.UIÄnderungsdatumSplitButton;
            WinComboBox    uICb_startComboBox             = this.UITransportAppWindow.UICb_startWindow.UICb_startComboBox;
            WinButton      uIStationsuchenButton          = this.UITransportAppWindow.UIStationsuchenWindow.UIStationsuchenButton;
            WinComboBox    uIBittegebenSieIhreStaComboBox = this.UITransportAppWindow.UICb_endWindow.UIBittegebenSieIhreStaComboBox;
            WinWindow      uIBittegebenSieIhreStaWindow   = this.UITransportAppWindow.UITransportAppClient.UIBittegebenSieIhreStaWindow;
            #endregion

            // Klicken "Transport App" Client
            Mouse.Click(uITransportAppClient, new Point(201, 162));

            // Doppelklicken "Verbindung suchen" Schaltfläche
            Mouse.DoubleClick(uIVerbindungsuchenButton, new Point(102, 23));

            // Doppelklicken "Verbindung suchen" Schaltfläche
            Mouse.DoubleClick(uIVerbindungsuchenButton, new Point(104, 25));

            // Klicken "Verbindung suchen" Schaltfläche
            Mouse.Click(uIVerbindungsuchenButton, new Point(104, 25));

            // Klicken "Verbindung suchen" Schaltfläche
            Mouse.Click(uIVerbindungsuchenButton, new Point(121, 22));

            // Klicken "Verbindung suchen" Schaltfläche
            Mouse.Click(uIVerbindungsuchenButton, new Point(121, 22));

            // Klicken "Transport App" Client
            Mouse.Click(uITransportAppClient, new Point(266, 113));

            // Klicken "Transport App" Client
            Mouse.Click(uITransportAppClient, new Point(274, 101));

            // Klicken "Transport App" Client
            Mouse.Click(uITransportAppClient, new Point(293, 113));

            // Klicken "Änderungsdatum" Unterteilte Schaltfläche
            Mouse.Click(uIÄnderungsdatumSplitButton, new Point(36, 13));

            // "huob" in "cb_start" Kombinationsfeld auswählen
            uICb_startComboBox.EditableItem = this.RecordedMethod4Params.UICb_startComboBoxEditableItem;

            // Klicken "&Station suchen" Schaltfläche
            Mouse.Click(uIStationsuchenButton, new Point(40, 15));

            // "megg" in "Bitte geben Sie Ihre Startstation ein:" Kombinationsfeld auswählen
            uIBittegebenSieIhreStaComboBox.EditableItem = this.RecordedMethod4Params.UIBittegebenSieIhreStaComboBoxEditableItem;

            // Klicken "Bitte geben Sie Ihre Startstation ein:" Fenster
            Mouse.Click(uIBittegebenSieIhreStaWindow, new Point(222, 86));

            // Klicken "Verbindung suchen" Schaltfläche
            Mouse.Click(uIVerbindungsuchenButton, new Point(135, 17));
        }
        /// <summary>
        /// Get UI WinSpltButton control using Control's search property
        /// </summary>
        /// <param name="window">Parent window of the control</param>
        /// <param name="name">Display Name of Control</param>
        /// <returns>WinSplitButton</returns>
        public static WinSplitButton GetWinSplitButton(this WinWindow window, string name)
        {
            var txtProps = new WinSplitButton(window)
            {
                TechnologyName = "MSAA"
            };

            txtProps.SearchProperties[WinSplitButton.PropertyNames.Name] = name;

            return(txtProps);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取窗口某个控件,并点击。适用于控件在窗口中唯一存在
        /// </summary>
        /// <param name="controltype">控件类型</param>
        /// 如梦:"DropDownButton"
        public void WindowControlTypeClick(string controltype)
        {
            //WinSplitButton
            //UIItemWindow

            WinSplitButton wsb = new WinSplitButton(browser);
            WinControl     wc  = new WinControl(wsb);

            wc.SearchProperties[WinControl.PropertyNames.ControlType] = controltype;
            Mouse.Click(wc);
        }
Exemplo n.º 5
0
        /// <summary>
        /// refresh
        /// </summary>
        public void refresh()
        {
            #region Variable Declarations
            WinTabPage     uIHomeTabPage = this.UIUntitledPowerQueryEdWindow.UIItemWindow.UIRibbonClient.UIHomeTabPage;
            WinSplitButton uIRefreshPreviewSplitButton = this.UIUntitledPowerQueryEdWindow.UIItemWindow.UIRefreshPreviewGroup.UIRefreshPreviewSplitButton;
            #endregion

            // Click 'Home' tab
            Mouse.Click(uIHomeTabPage, new Point(34, 13));

            // Click 'Refresh Preview' split button
            Mouse.Click(uIRefreshPreviewSplitButton, new Point(20, 22));
        }
Exemplo n.º 6
0
        /// <summary>
        /// ImportThresholds - Use 'ImportThresholdsParams' to pass parameters into this method.
        /// </summary>
        public void ImportThresholds(String fileName)
        {
            #region Variable Declarations
            WinButton      uIImportButton     = this.UISmartViewRecipeManagWindow.UIThresholdsStationVieWindow.UIImportWindow.UIImportButton;
            WinComboBox    uIFilenameComboBox = this.UIImportThresholdSettiWindow.UIItemWindow.UIFilenameComboBox;
            WinSplitButton uIOpenSplitButton  = this.UIImportThresholdSettiWindow.UIOpenWindow.UIOpenSplitButton;
            #endregion

            // Click 'Import...' button
            Mouse.Click(uIImportButton, new Point(45, 15));

            // Select 'AlternateThresholds-AtEdges.txt' in 'File name:' combo box
            uIFilenameComboBox.EditableItem = fileName;

            // Click '&Open' split button
            Mouse.Click(uIOpenSplitButton, new Point(50, 11));
        }
Exemplo n.º 7
0
        /// <summary>
        /// SaveXLSX
        /// </summary>
        public void SaveXLSX()
        {
            #region Variable Declarations
            WinSplitButton uISaveSplitButton  = this.UIAllFormDataInternetEWindow.UINotificationToolBar.UISaveSplitButton;
            WinButton      uIOpenfolderButton = this.UIAllFormDataInternetEWindow.UINotificationToolBar.UIOpenfolderButton;
            #endregion

            // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
            Playback.PlaybackSettings.ContinueOnError = true;

            // Click 'Save' split button
            Mouse.Click(uISaveSplitButton, new Point(49, 21));

            // Click 'Open folder' button
            Mouse.Click(uIOpenfolderButton, new Point(114, 21));

            // Reset flag to ensure that play back stops if there is an error.
            Playback.PlaybackSettings.ContinueOnError = false;
        }
Exemplo n.º 8
0
        /// <summary>
        /// DefineAnalysisTextural - Use 'DefineAnalysisTexturalParams' to pass parameters into this method.
        /// </summary>
        public void DefineAnalysisTextural()
        {
            #region Variable Declarations
            WinClient      uIAnalysismethodsClient  = this.UISmartViewRecipeManagWindow.UISheetQualityAnalysisWindow.UIItemWindow11.UIAnalysismethodsClient;
            WinClient      uIAnalysismethodsClient1 = this.UISmartViewRecipeManagWindow.UISheetQualityAnalysisWindow.UIItemWindow12.UIAnalysismethodsClient;
            WinComboBox    uIFilenameComboBox       = this.UISQAConfigurationWindow.UIItemWindow.UIFilenameComboBox;
            WinSplitButton uIOpenSplitButton        = this.UISQAConfigurationWindow.UIOpenWindow.UIOpenSplitButton;
            #endregion

            // Click 'Analysis methods' client
            Mouse.Click(uIAnalysismethodsClient, new Point(116, 28));

            // Double-Click 'Analysis methods' client
            Mouse.DoubleClick(uIAnalysismethodsClient1, new Point(116, 28));

            // Select 'maximumvalue.txt' in 'File name:' combo box
            uIFilenameComboBox.EditableItem = this.DefineAnalysisTexturalParams.UIFilenameComboBoxEditableItem;

            // Click '&Open' split button
            Mouse.Click(uIOpenSplitButton, new Point(43, 14));
        }
        public WinSplitButton CardTypeCollectionButton()
        {
            WinWindow ItemWindow = new WinWindow(GetMainWindow());
            ItemWindow.SearchProperties[WinWindow.PropertyNames.ControlId] = "59392";
            ItemWindow.SearchProperties[WinWindow.PropertyNames.Instance] = "3";
            ItemWindow.WindowTitles.Add((new PropertyExpression(WinWindow.PropertyNames.Name, "LOWIS:", PropertyExpressionOperator.Contains).ToString()));

            WinSplitButton CardType = new WinSplitButton(ItemWindow);
            CardType.SearchProperties[WinButton.PropertyNames.Name] = "Card Type Collection";
            CardType.WindowTitles.Add((new PropertyExpression(WinWindow.PropertyNames.Name, "LOWIS:", PropertyExpressionOperator.Contains).ToString()));

            return (CardType);
        }
Exemplo n.º 10
0
        public void TC02_RetrieveNewLink()
        {
            DiscussGroupLinkService linkService = new DiscussGroupLinkService();
            List <DiscussGroupLink> list        = linkService.getByStatus(EntityStatus.Waiting);

            Console.WriteLine("获得{0}条未处理的DiscussGroupLink", list.Count);

            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                DiscussGroupLink link = list[i];
                Console.WriteLine("处理DiscussGroupLink, ID={0}", link.ID);

                string root    = (new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location)).Directory.FullName;
                string exeFile = root + "\\files\\ShowNotify.exe";
                Process.Start(exeFile, "2000 " + string.Format("正在处理:{0}/{1}", i, count));

                try
                {
                    linkService.UpdateStatus(link.ID, EntityStatus.Processing, "处理中");
                    string newLink = "";

                    //QQ讨论组
                    if (link.LinkType == "Z")
                    {
                        string oldLink = link.OldLink;

                        //使用默认浏览器(IE)打开指定地址
                        Console.WriteLine("[{0}] 打开IE浏览器", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        JoinTalkWebPage jtPage = new JoinTalkWebPage();
                        jtPage.LaunchUrl(new System.Uri(oldLink));
                        //点击“加入多人聊天”按钮
                        Console.WriteLine("[{0}] 点击“加入多人聊天”按钮", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        jtPage.JoinTalkDoc.BtnJoinTalk.WaitForControlExist();
                        Mouse.Click(jtPage.JoinTalkDoc.BtnJoinTalk);
                        //关闭浏览器
                        Console.WriteLine("[{0}] 关闭浏览器", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        jtPage.Close();
                        jtPage.WaitForControlNotExist();

                        //获取聊天对话框
                        Console.WriteLine("[{0}] 获取聊天对话框", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        QQTalkWindow window = new QQTalkWindow();
                        //获取工具条按钮
                        Console.WriteLine("[{0}] 获取工具条按钮", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        WinSplitButton btnJoinTalk = window.TalkToolBar.BtnJoinTalk;
                        //点击“邀请加入多人聊天”
                        Console.WriteLine("[{0}] 点击“邀请加入多人聊天”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Mouse.Click(btnJoinTalk);

                        //获取弹出窗口
                        Console.WriteLine("[{0}] 获取弹出窗口", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        JoinTalkWindow jtWin = new JoinTalkWindow();
                        //等待弹出窗口显示完毕
                        Console.WriteLine("[{0}] 等待弹出窗口显示完毕", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        jtWin.JoinTalkMenu.JoinTalkItem.WaitForControlExist();
                        //点击“复制邀请链接”
                        Console.WriteLine("[{0}] 点击“复制邀请链接”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Mouse.Click(jtWin.JoinTalkMenu.JoinTalkItem);
                        Console.WriteLine("[{0}] 休眠1秒钟", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Thread.Sleep(1000);

                        //从黏贴板中读取新邀请链接
                        Console.WriteLine("[{0}] 从黏贴板中读取新邀请链接", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        newLink = Clipboard.GetText();
                        if (!string.IsNullOrWhiteSpace(newLink) && newLink.StartsWith("点击链接加入多人聊天"))
                        {
                            newLink = Clipboard.GetText().Split("\r\n".ToCharArray())[1];
                        }

                        //Keyboard.SendKeys(window.Input, ":) just for holding this group. sorry to bother.");
                        //Keyboard.SendKeys(window.Input, KeyboardKeys.ENTER);

                        //关闭讨论组标签
                        Console.WriteLine("[{0}] 关闭讨论组标签", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Keyboard.SendKeys(window, KeyboardKeys.ESC);
                    }
                    else
                    {
                        //QQ群
                    }

                    //保存新Url,http://url.cn/5rUmF4D
                    if (!string.IsNullOrWhiteSpace(newLink))
                    {
                        linkService.UpdateNewLink(link.ID, newLink);
                    }
                    else
                    {
                        linkService.UpdateStatus(link.ID, EntityStatus.Fail, "获取新链接失败");
                    }
                }
                catch (Exception ex)
                {
                    linkService.UpdateStatus(link.ID, EntityStatus.Fail, HttpUtility.UrlEncode(ex.Message));
                }

                //break;
            }
        }
Exemplo n.º 11
0
        public void TC04_GetQQTaoLunZuList()
        {
            OrigionLinkService olService = new OrigionLinkService();

            MsgManWindow mmw = new MsgManWindow();

            Mouse.Click(mmw.MsgManTabs.MultipleTalksTabPage);
            Mouse.Click(mmw.LeftList.MyMultipleTalk);

            WinListItem last = null;
            int         i    = 0;

            while (mmw.HasNext(mmw.MidList, i))
            {
                if (last != null)
                {
                    Mouse.Click(last);
                    Keyboard.SendKeys(KeyboardKeys.DOWN);
                }

                WinListItem item = mmw.Next(mmw.MidList, i);
                Mouse.DoubleClick(item);

                #region
                //获取聊天对话框
                Console.WriteLine("[{0}] 获取聊天对话框", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                QQTalkWindow window = new QQTalkWindow();
                //获取工具条按钮
                Console.WriteLine("[{0}] 获取工具条按钮", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                WinSplitButton btnJoinTalk = window.TalkToolBar.BtnJoinTalk;
                //点击“邀请加入多人聊天”
                Console.WriteLine("[{0}] 点击“邀请加入多人聊天”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                Mouse.Click(btnJoinTalk);

                //获取弹出窗口
                Console.WriteLine("[{0}] 获取弹出窗口", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                JoinTalkWindow jtWin = new JoinTalkWindow();
                //等待弹出窗口显示完毕
                Console.WriteLine("[{0}] 等待弹出窗口显示完毕", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                jtWin.JoinTalkMenu.JoinTalkItem.WaitForControlExist();
                //点击“复制邀请链接”
                Console.WriteLine("[{0}] 点击“复制邀请链接”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                //Mouse.Click(jtWin.JoinTalkMenu.JoinTalkItem);
                Keyboard.SendKeys(KeyboardKeys.DOWN);
                Keyboard.SendKeys(KeyboardKeys.DOWN);
                Keyboard.SendKeys(KeyboardKeys.ENTER);
                Console.WriteLine("[{0}] 休眠1秒钟", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                Thread.Sleep(1000);

                //从黏贴板中读取新邀请链接
                Console.WriteLine("[{0}] 从黏贴板中读取新邀请链接", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                string newLink = Clipboard.GetText();
                if (!string.IsNullOrWhiteSpace(newLink) && newLink.StartsWith("点击链接加入多人聊天"))
                {
                    newLink = Clipboard.GetText().Split("\r\n".ToCharArray())[1];
                }

                //关闭讨论组标签
                Console.WriteLine("[{0}] 关闭讨论组标签", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                Keyboard.SendKeys(window, KeyboardKeys.ESC);
                #endregion

                OrigionLink link = new OrigionLink()
                {
                    QQOwner      = "",
                    RetrieveDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")),
                    Type         = "Z",
                    Name         = item.Name.Substring(0, 1000),
                    JoinLink     = newLink
                };

                try
                {
                    olService.Insert(link);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(link.ToString());
                    Console.WriteLine(ex.Message);
                }

                last = item;
                //if (++i >= 595) break;
            }
        }
Exemplo n.º 12
0
        private static void TranslateTestData(string[] testDataRow)
        {
            string[] dataRow = testDataRow;
            //check key word
            string keyWord = dataRow[2].Trim();
            //text of web element
            string elementText;

            //if steps begins with %, skip it
            if (dataRow[1].Trim().Substring(0, 1) == "%")
            {
                keyWord = "%";
            }
            switch (keyWord)
            {
            //if key word is "SetScreenResolution"
            case "SetScreenResolution":
                string   resolution      = dataRow[5].Trim();
                string[] resolutionArray = resolution.Split(new Char[] { ',', ';', '*' });
                screenResolution = new Size(Convert.ToInt32(resolutionArray[0].Trim()), Convert.ToInt32(resolutionArray[1].Trim()));
                if (TestExecuter.driver != null)
                {
                    TestExecuter.driver.Manage().Window.Size = screenResolution;
                    TestExecuter.driver.Manage().Window.Position = new Point(0, 0);
                }
                break;

            //if key word is "OpenBrowser"
            case "OpenBrowser":
                //check Para
                string browserName = dataRow[5].Trim().ToUpper();

                if (browserName == "IE")      //open IE
                {
                    var options = new InternetExplorerOptions
                    {
                        BrowserAttachTimeout = TimeSpan.FromSeconds(30),
                        RequireWindowFocus   = false,
                        IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                        IgnoreZoomLevel    = true,
                        EnsureCleanSession = true,
                        //PageLoadStrategy = InternetExplorerPageLoadStrategy.Normal,
                        //ValidateCookieDocumentType = true,
                        InitialBrowserUrl           = "about:Tabs",
                        BrowserCommandLineArguments = "-noframemerging"
                    };
                    TestExecuter.driver = new InternetExplorerDriver(@"..\..\..\KeywordDrivenTest\Bin\Debug", options, TimeSpan.FromSeconds(30));
                }
                else
                {
                    if (browserName == "CHROME")      //open Chrome
                    {
                        TestExecuter.driver = new ChromeDriver(@"..\..\..\KeywordDrivenTest\Bin\Debug");
                    }
                    else       //error message
                    {
                        TestExecuter.sw.WriteLine("Browser is not supported ! Please input 'IE' or 'Chrome' in Excel file. ");
                        TestExecuter.testResult = false;
                        break;
                    }
                }
                TestExecuter.driver.Manage().Window.Size = screenResolution;
                TestExecuter.driver.Manage().Window.Position = new Point(0, 0);
                // Set implicit wait timeouts to 60 secs
                TestExecuter.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
                ICapabilities capabilities = ((RemoteWebDriver)TestExecuter.driver).Capabilities;
                TestExecuter.sw.WriteLine(@"Browser Version: <" + browserName + " " + capabilities.Version + ">");
                break;

            //if key word is "NavigateTo"
            case "NavigateTo":
                //go to URL
                TestExecuter.driver.Navigate().GoToUrl(dataRow[5].Trim());
                break;

            //if key word is "SendKeys"
            case "SendKeys":
                GetElement(dataRow[3], dataRow[4]).Clear();
                ((IJavaScriptExecutor)TestExecuter.driver).ExecuteScript("arguments[0].style.opacity='1'", GetElement(dataRow[3], dataRow[4]));
                GetElement(dataRow[3], dataRow[4]).SendKeys(dataRow[5].Trim());
                break;

            //if key word is "SendKeys"
            case "SendControlKeys":
                SendControlKeys(dataRow[3], dataRow[4], dataRow[5]);
                break;

            //if key word is "Click"
            case "Click":
                if (TestExecuter.driver != null)
                {
                    //get text from what you click
                    oldWindowHandle = TestExecuter.driver.CurrentWindowHandle;
                    string txt = GetElement(dataRow[3], dataRow[4]).Text;
                    ((IJavaScriptExecutor)TestExecuter.driver).ExecuteScript("arguments[0].click();", GetElement(dataRow[3], dataRow[4]));
                    //if it is not download operation
                    if (!txt.ToUpper().Contains("DOWNLOAD"))
                    {
                        //go to latest window
                        TestExecuter.driver.SwitchTo().Window(TestExecuter.driver.WindowHandles.Last());
                        newWindowHandle = TestExecuter.driver.CurrentWindowHandle;
                    }
                    //if it is open button to load client
                    if (txt.ToUpper().Equals("OPEN"))
                    {
                        //maximize windows
                        List <string> lstWindow = TestExecuter.driver.WindowHandles.ToList();
                        foreach (var handle in lstWindow)
                        {
                            if (TestExecuter.driver.SwitchTo().Window(handle).Manage().Window.Size.Height != screenResolution.Height)
                            {
                                TestExecuter.driver.SwitchTo().Window(handle).Manage().Window.Size     = screenResolution;
                                TestExecuter.driver.SwitchTo().Window(handle).Manage().Window.Position = new Point(0, 0);
                            }
                        }
                    }
                    txt = null;
                }

                break;

            //if key word is "DoubleClick"
            case "DoubleClick":
                //get old window handle before double click
                if (TestExecuter.driver != null)
                {
                    oldWindowHandle = TestExecuter.driver.CurrentWindowHandle;
                }
                //create Actions object
                Actions doubleClickBuilder = new Actions(TestExecuter.driver);
                //double click action
                doubleClickBuilder.DoubleClick(GetElement(dataRow[3], dataRow[4])).Build().Perform();
                //get new window handle after click
                TestExecuter.driver.SwitchTo().Window(TestExecuter.driver.WindowHandles.Last());
                newWindowHandle = TestExecuter.driver.CurrentWindowHandle;
                //max new window
                if (oldWindowHandle != newWindowHandle)
                {
                    TestExecuter.driver.Manage().Window.Maximize();
                }
                break;

            //if key word is "MoveToElement"
            case "MoveToElement":
                //create Actions object
                Actions moveToBuilder = new Actions(TestExecuter.driver);
                //move to element action
                moveToBuilder.MoveToElement(GetElement(dataRow[3], dataRow[4])).Build().Perform();
                break;

            //if key word is "Wait"
            case "Wait":
                int s = Convert.ToInt32(dataRow[5].Trim());     //s is second
                Thread.Sleep(s * 1000);
                break;

            //if key word is "RefreshPage"
            case "RefreshPage":
                Actions actions = new Actions(TestExecuter.driver);
                actions.KeyDown(OpenQA.Selenium.Keys.Control).SendKeys(OpenQA.Selenium.Keys.F5).Perform();
                break;

            //if key word is "ScrollToElement"
            case "ScrollToElement":
                ((IJavaScriptExecutor)TestExecuter.driver).ExecuteScript("arguments[0].scrollIntoView();", GetElement(dataRow[3], dataRow[4]));
                break;

            //if key word is "GetElement(dataRow[3], dataRow[4])"
            case "SwitchToFrame":
                TestExecuter.driver.SwitchTo().Frame(GetElement(dataRow[3], dataRow[4]));
                break;

            //if key word is "VerifyElementExist"
            case "VerifyElementExist":
                if (!GetElement(dataRow[3], dataRow[4]).Displayed)
                {
                    TestExecuter.sw.WriteLine("Test failed in step: <" + dataRow[1] + ">, Reason: ");
                    TestExecuter.sw.WriteLine("Web Element" + dataRow[4].ToString() + "is not displayed !");
                    TestExecuter.testResult = false;
                }
                else
                {
                    //if it is client selection page
                    if (dataRow[4].Trim() == ".//*[@id='client-selection-form']/div[1]/span[1]")
                    {
                        if (TestExecuter.driver.FindElement(By.XPath(".//*[@id='client-selection-form']/div[1]/span[1]")).Text.Trim().Length < 28)
                        {
                            TestExecuter.sw.WriteLine("RealSuite Version: < XXX >");
                        }
                        else
                        {
                            TestExecuter.buildVersion = TestExecuter.driver.FindElement(By.XPath(".//*[@id='client-selection-form']/div[1]/span[1]")).Text.Trim().Substring(18, 10);
                            //write build version to log
                            TestExecuter.sw.WriteLine("RealSuite Version: <" + TestExecuter.buildVersion + ">");
                        }
                    }
                }
                break;

            //if key word is "VerifyValueGreaterThan"
            case "VerifyValueGreaterThan":
                elementText = GetElement(dataRow[3], dataRow[4]).Text;
                if (Convert.ToDouble(elementText) <= Convert.ToDouble(dataRow[5]))
                {
                    TestExecuter.sw.WriteLine("Test failed in step: <" + dataRow[1] + ">, Reason:");
                    TestExecuter.sw.WriteLine("Web Element <" + dataRow[3] + " : " + dataRow[4].ToString() + "> is not greater than " + "'" + dataRow[5] + "'");
                    TestExecuter.testResult = false;
                }
                break;

            //if key word is "VerifyValueLessThan"
            case "VerifyValueLessThan":
                elementText = GetElement(dataRow[3], dataRow[4]).Text;
                if (Convert.ToDouble(elementText) >= Convert.ToDouble(dataRow[5]))
                {
                    TestExecuter.sw.WriteLine("Test failed in step: <" + dataRow[1] + ">, Reason:");
                    TestExecuter.sw.WriteLine("Web Element <" + dataRow[3] + " : " + dataRow[4].ToString() + "> is not less than " + "'" + dataRow[5] + "'");
                    TestExecuter.testResult = false;
                }
                break;

            //if key word is "VerifyValueEqualTo"
            case "VerifyValueEqualTo":
                elementText = GetElement(dataRow[3], dataRow[4]).Text.Trim();
                if (elementText != dataRow[5].Trim())
                {
                    TestExecuter.sw.WriteLine("Test failed in step: <" + dataRow[1] + ">, Reason:");
                    TestExecuter.sw.WriteLine("Web Element <" + dataRow[3] + " : " + dataRow[4].ToString() + "> is not equal to " + "'" + dataRow[5] + "'");
                    TestExecuter.testResult = false;
                }
                break;

            //if key word is "VerifyValueNotEqualTo"
            case "VerifyValueNotEqualTo":
                elementText = GetElement(dataRow[3], dataRow[4]).Text.Trim();
                if (elementText == dataRow[5].Trim())
                {
                    TestExecuter.sw.WriteLine("Test failed in step: <" + dataRow[1] + ">, Reason:");
                    TestExecuter.sw.WriteLine("Web Element <" + dataRow[3] + " : " + dataRow[4].ToString() + "> is equal to " + "'" + dataRow[5] + "'");
                    TestExecuter.testResult = false;
                }
                break;

            //if key word is "VerifyValueContain"
            case "VerifyValueContain":
                elementText = GetElement(dataRow[3], dataRow[4]).Text;
                if (!elementText.Contains(dataRow[5]))
                {
                    TestExecuter.sw.WriteLine("Test failed in step: <" + dataRow[1] + ">, Reason:");
                    TestExecuter.sw.WriteLine("Web Element <" + dataRow[3] + " : " + dataRow[4].ToString() + "> doesn't contain " + "'" + dataRow[5] + "'");
                    TestExecuter.testResult = false;
                }
                break;

            //if key word is "VerifyValueNotContain"
            case "VerifyValueNotContain":
                elementText = GetElement(dataRow[3], dataRow[4]).Text;
                if (elementText.Contains(dataRow[5]))
                {
                    TestExecuter.sw.WriteLine("Test failed in step: <" + dataRow[1] + ">, Reason:");
                    TestExecuter.sw.WriteLine("Web Element <" + dataRow[3] + " : " + dataRow[4].ToString() + "> doesn't contain " + "'" + dataRow[5] + "'");
                    TestExecuter.testResult = false;
                }
                break;

            //if key word is "GoToNextWindow"
            case "GoToNextWindow":
                TestExecuter.driver.SwitchTo().Window(newWindowHandle);
                break;

            //if key word is "GoToNextWindow"
            case "GotoPreviousWindow":
                TestExecuter.driver.SwitchTo().Window(oldWindowHandle);
                break;

            //if key word is "CloseBrowser"
            case "CloseBrowser":
                TestExecuter.driver.Close();
                break;

            //if key word is "WinSaveFile"
            case "WinSaveFile(IE11)":
                string        titleDownload         = TestExecuter.driver.Title;
                BrowserWindow browserWindowDownload = new BrowserWindow();
                browserWindowDownload.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
                browserWindowDownload.WindowTitles.Add(titleDownload);
                WinToolBar notificationBar = new WinToolBar(browserWindowDownload);
                notificationBar.SearchProperties.Add(WinToolBar.PropertyNames.Name, "Notification", PropertyExpressionOperator.EqualTo);
                WinSplitButton saveButton = new WinSplitButton(notificationBar);
                saveButton.SearchProperties.Add(WinButton.PropertyNames.Name, "Save", PropertyExpressionOperator.EqualTo);
                Mouse.Click(saveButton);
                break;

            //if key word is "WinClickOK"
            case "WinClickOK(IE11)":
                string        titlePop = TestExecuter.driver.Title;
                BrowserWindow browser  = new BrowserWindow();
                browser.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
                browser.WindowTitles.Add(titlePop);
                WinWindow pop = new WinWindow(null);
                pop.SearchProperties.Add(WinWindow.PropertyNames.Name, "Message from webpage", PropertyExpressionOperator.EqualTo);
                WinButton ok = new WinButton(pop);
                ok.SearchProperties.Add(WinButton.PropertyNames.Name, "OK", PropertyExpressionOperator.EqualTo);
                Mouse.Click(ok);
                break;

            //if key word is "WinUploadFile"
            case "WinUploadFile":
                WinWindow UploadWindow = new WinWindow(null);
                UploadWindow.SearchProperties.Add("Name", "Choose File to Upload");
                WinEdit FileNameEdit = new WinEdit(UploadWindow);
                FileNameEdit.SearchProperties.Add("Name", "File name:");
                WinButton OpenBtn = new WinButton(UploadWindow);
                OpenBtn.SearchProperties.Add("Name", "Open");
                Keyboard.SendKeys(FileNameEdit, @"C:\Users\pans\Downloads\53360.txt");
                Mouse.Click(OpenBtn);
                break;

            default:
                break;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 获取窗口某个控件,并点击。适用于控件在窗口中唯一存在
        /// </summary>
        /// <param name="controltype">控件类型</param>
        /// 如梦:"DropDownButton"
        public void WindowControlTypeClick(string controltype)
        {
            //WinSplitButton
            //UIItemWindow

            WinSplitButton wsb = new WinSplitButton(browser);
            WinControl wc = new WinControl(wsb);
            wc.SearchProperties[WinControl.PropertyNames.ControlType] = controltype;
            Mouse.Click(wc);
        }