Program.cs 2.08 KB
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace CentralDispatcher
{
    class Program
    {

        private static readonly string titlePageUrl = "https://www.centraldispatch.com/";
        private static readonly string userName = "Empo101";
        private static readonly string password = "Miamiheat1";

        static void Main(string[] args)
        {
           
            var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
            var chromedriverPath = new FileInfo(location.AbsolutePath).Directory.ToString();
            // var options = new ChromeOptions();
            //   options.AddArguments("--headless", "--log-level=3", "--no-sandbox", "--disable-web-security", "--disable-gpu", "--incognito", "--hide-scrollbars");
            //  options.AddUserProfilePreference("profile.default_content_setting_values.images", 2);
            //  using (
            var driver = new ChromeDriver(chromedriverPath);
                
             //   )
          //  {
                driver.Navigate().GoToUrl(titlePageUrl);



                Actions action = new Actions(driver);
                action.KeyDown(Keys.Control).SendKeys(Keys.F12).
                    KeyUp(Keys.Control).
                    Perform();

                var btn = driver.FindElementsByClassName("loginBtn").ToArray().Where(x => x.Location.X != 0 && x.Location.Y != 0).FirstOrDefault();

                btn.Click();

                var email = driver.FindElementById("username");
                var pass = driver.FindElementById("password");

                email.SendKeys(userName);
                pass.SendKeys(password);


                var submit = driver.FindElement(By.XPath("//button[@type='submit'][text()='Login']"));
                submit.Click();

                var body_html = driver.PageSource;

         //   }
         
        }     
    }
}