关于按钮点击的非常具体的案例

Very specific case regarding button click

我正在创建实用程序控制台应用程序以帮助我在我的大学注册某些 类。到目前为止,我已经让它下载网站的内容并经常检查特定的更改,这会在给定课程已满或可以参加时向我提供信息。像那样:

WebRequest request2 = WebRequest.Create("https://usosweb.umk.pl/kontroler.php?_action=katalog2/przedmioty/pokazPrzedmiot&prz_kod=0600-OG-ChH");
request2.Method = "GET";
WebResponse response2 = request2.GetResponse();
Stream stream2 = response2.GetResponseStream();
StreamReader reader2 = new StreamReader(stream2);
string content_2 = reader2.ReadToEnd();
string drugi = getBetween(content_2, @"Stan zapełnienia grup:</b>
        <b>", "</b> (zarejestrowanych/limit)");

reader2.Close();
response2.Close();

if (drugi != pierwszy)
{
    Console.WriteLine("Rejestracja!");
    Console.Beep(3200, 900);
    System.Diagnostics.Process.Start("https://usosweb.umk.pl/kontroler.php?_action=katalog2/przedmioty/pokazPrzedmiot&prz_kod=0600-OG-ChH");
    pierwszy = drugi;
}

问题是它仍然需要我全神贯注,因为我让它只打开带有注册按钮的网站,我的目标是让它在插槽打开后自动点击它。

注意事项:

毕竟,这可能吗?我可以通过编码吗?我使用的是 C#,但可以添加一些其他语言的代码片段,如果这样可以更容易或可能的话。

我认为对于这种任务自动化Selenium WebDriver是最好的工具

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Chrome;


namespace WEBDRIVER
{
  class Program
  {
    static void Main(string[] args)
    {
      IWebDriver driver = new ChromeDriver();
      driver.Navigate().GoToUrl("http://www.google.com/");
      IWebElement query = driver.FindElement(By.Name("q"));
      query.SendKeys("banana");
      query.Submit();

      WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
      wait.Until((d) => { return d.Title.ToLower().StartsWith("banana"); });

      System.Console.WriteLine("Page title is: " + driver.Title);
      driver.Quit();
    }
  }
}