示例#1
0
 protected override void Do(IEvent e)
 {
     if (e.Data.Count < 1)
     {
         return;
     }
     ClickLinkTask.Execute(WebAutomationHelper.ParseElementByXPath(e.Webbrowser.Document.Body, e.Data[0]));
 }
示例#2
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            #region Navigate task

            if (this.cbTasks.SelectedIndex == 0)
            {
                //we use a function for this task since we reuse it in other examples
                this.LoadPageInBrowser();
                this.WriteLog("Navigated to page.");
            }

            #endregion

            #region Screen shot task

            if (this.cbTasks.SelectedIndex == 1)
            {
                this.LoadPageInBrowser();

                MakeScreenShotTask screenShotTask = new MakeScreenShotTask();
                string             message        = screenShotTask.Execute(this.webBrowser, ConfigurationManager.AppSettings.Get("picture.path"), "testPicture.jpeg");
                this.WriteLog(message);
            }

            #endregion

            #region Click button task

            if (this.cbTasks.SelectedIndex == 2)
            {
                this.LoadPageInBrowser();

                ClickButtonTask clickButtonTask = new ClickButtonTask();
                HtmlElement     buttonToClick   = this.FindControlByName("Button", this.webBrowser.Document.All);
                string          message         = clickButtonTask.Execute(this.webBrowser, buttonToClick);
                this.WriteLog(message);
            }

            #endregion

            #region Fill data task

            if (this.cbTasks.SelectedIndex == 3)
            {
                this.LoadPageInBrowser();

                EntryDataTask entryDataTask = new EntryDataTask();
                HtmlElement   textBox       = this.FindControlByName("TextBox", this.webBrowser.Document.All);
                string        message       = entryDataTask.Execute(textBox, "Hello from program!!!");
                this.WriteLog(message);
            }

            #endregion

            #region Click link data task

            if (this.cbTasks.SelectedIndex == 4)
            {
                this.LoadPageInBrowser();

                ClickLinkTask clickTask   = new ClickLinkTask();
                HtmlElement   linkToClick = this.FindControlByTag("A", this.webBrowser.Document.All);
                string        message     = clickTask.Execute(linkToClick);
                this.WriteLog(message);
            }

            #endregion

            #region Select a radio button task

            if (this.cbTasks.SelectedIndex == 5)
            {
                this.LoadPageInBrowser();

                SelectRadioButtonTask selectRadioButtonTask = new SelectRadioButtonTask();
                HtmlElement           linkToClick           = this.FindControlByName("Radio3", this.webBrowser.Document.All);
                string message = selectRadioButtonTask.Execute(linkToClick);
                this.WriteLog(message);
            }

            #endregion

            #region Select a value from list box task

            if (this.cbTasks.SelectedIndex == 6)
            {
                this.LoadPageInBrowser();

                SelectListTask selectListTask = new SelectListTask();
                HtmlElement    listBox        = this.FindControlByName("List", this.webBrowser.Document.All);
                string         message        = selectListTask.Execute(listBox, "Second");
                this.WriteLog(message);
            }

            #endregion
        }