Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 关于按钮点击的非常具体的案例_C#_Button_Get - Fatal编程技术网

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

C# 关于按钮点击的非常具体的案例,c#,button,get,C#,Button,Get,我正在创建实用程序控制台应用程序,帮助我注册我大学的某些课程。到目前为止,我已经让它下载网站的内容,并经常检查具体的变化,这给了我一个信息,当给定的课程是完整的或可采取的。就像这样: WebRequest request2 = WebRequest.Create("https://usosweb.umk.pl/kontroler.php?_action=katalog2/przedmioty/pokazPrzedmiot&prz_kod=0600-OG-ChH"); request2.M

我正在创建实用程序控制台应用程序,帮助我注册我大学的某些课程。到目前为止,我已经让它下载网站的内容,并经常检查具体的变化,这给了我一个信息,当给定的课程是完整的或可采取的。就像这样:

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;
}
问题是,它仍然需要我的全力关注,因为我只让它在注册按钮打开的情况下打开网站,我的目标是让它在插槽打开后自动点击它

需要注意的几件事:

  • 我必须登录该网站才能注册课程

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

    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();
        }
      }
    }
    

    打得好,建议硒!谢谢我马上就去试试。