/// <summary> /// Logs in using the stored username and password, and then navigates to the desired url. /// </summary> public void Login(IWebDriver driver, FspScraperOptions options) { // navigate to login page and login, then navigate to desired page and verify we're at the right url driver.Navigate().GoToUrl(options.AircraftUrl); // this will automatically open the login page and redirect after login driver.FindElement(By.Id("username")).SendKeys(options.FspUser); driver.FindElement(By.Id("password")).SendKeys(options.FspPass + Keys.Enter); Assert.AreEqual(options.AircraftUrl, driver.Url); }
public TimesScraperJob(ApplicationContext context, ITimesScraper scraper, ILogger <TimesScraperJob> logger, IOptions <FspScraperOptions> optionsAccessor) { _context = context; _scraper = scraper; _logger = logger; Options = optionsAccessor.Value; }
/// <summary> /// Initializes Chromedriver and then navigates to the desired page, scrapes, parses, and returns an ISet of the entity. /// This assumes that you have a chromedriver binary set in your path. /// </summary> public ISet <Times> Run(FspScraperOptions options) { // Run in headless mode - requires version 59 or greater var chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("headless"); IWebDriver driver = new ChromeDriver(chromeOptions); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); Login(driver, options); var times = ScrapeTimes(driver, wait); driver.Quit(); return(times); }