private void LoginClick(object sender, RoutedEventArgs e, SeleniumClass selenium) { if (selenium.Login()) { SelectButton.IsEnabled = true; } }
private void SelectClick(object sender, RoutedEventArgs e, SeleniumClass selenium) { if (selenium.SelectGroup()) { DownloadButton.IsEnabled = true; } }
public MainWindow() { DatabaseClass databaseClass = new DatabaseClass(monitor12); EventCreatorClass eventCreatorClass = new EventCreatorClass(monitor12, monitor23, databaseClass, events); EventLoaderClass eventLoaderClass = new EventLoaderClass(monitor23, events); List <Thread> threads = new List <Thread>(); InitializeComponent(); SeleniumClass selenium = new SeleniumClass(ComboGroup, ComboSemester, INFO, USER, PASS, HIDE); StartButton.Click += (sender, EventArgs) => StartButton_Click(sender, EventArgs, databaseClass, eventCreatorClass, eventLoaderClass, threads); CancelButton.Click += (sender, EventArgs) => Cancel_Click(sender, EventArgs, threads); LoginButton.Click += (sender, EventArgs) => LoginClick(sender, EventArgs, selenium); SelectButton.Click += (sender, EventArgs) => SelectClick(sender, EventArgs, selenium); DownloadButton.Click += (sender, EventArgs) => DownloadClick(sender, EventArgs, selenium); }
public bool Login() { try { var chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("--window-size=800,600"); chromeOptions.AddArguments("--disable-gpu"); chromeOptions.AddArguments("--disable-extensions"); chromeOptions.AddArguments("--proxy-server='direct://'"); chromeOptions.AddArguments("--proxy-bypass-list=*"); chromeOptions.AddArguments("--start-maximized"); bool check = HIDE.IsChecked ?? false; if (check) { chromeOptions.AddArguments("--headless"); } var driverService = ChromeDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; Driver = new ChromeDriver(driverService, chromeOptions); Task.Run(() => SeleniumClass.AllowHeadlessDownload(driverService)); Driver.Navigate().GoToUrl("https://s1.wcy.wat.edu.pl/ed1/"); Driver.FindElement(By.Name("userid")).SendKeys(USER.Text); Driver.FindElement(By.Name("password")).SendKeys(PASS.Password.ToString()); Driver.FindElement(By.ClassName("inputLogL")).Click(); try { var err = Driver.FindElement(By.ClassName("bError")); INFO.Text = Driver.FindElement(By.ClassName("bError")).Text; return(false); } catch { INFO.Text = "ACCESS GRANTED"; return(true); } } catch { Application.Current.Dispatcher.Invoke(delegate { INFO.Text = "BROWSER ERROR"; }); return(false); } }
private void DownloadClick(object sender, RoutedEventArgs e, SeleniumClass selenium) { selenium.Download(); }