Program.cs
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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;
// }
}
}
}