Суббота, Май 30, 2020

Жмет кнопку на сайте

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace autoeuslugi
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            webBrowser1.Navigate("ваш сайт");
            //webBrowser1.DocumentCompleted += OnDocumentComplete;
            
        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser webBrowser = sender as WebBrowser;
            if (webBrowser == null)
                return;
            HtmlElementCollection select = webBrowser.Document.GetElementsByTagName("select");
            HtmlElement comboBox = null;
            for (int i = 0; i < select.Count; i++)
            {
                comboBox = select[i];
                comboBox.SetAttribute("value", "5");
                break;
            }
            HtmlElement he = webBrowser.Document.GetElementById("voteSendButton");
            if (he != null)
                he.InvokeMember("click");
        }
    }
}

Back to Top