public async Task Login(string loginUrl, string username, string brfId) { if (string.IsNullOrEmpty(loginUrl)) { throw new ArgumentNullException(nameof(loginUrl)); } if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException(nameof(username)); } if (string.IsNullOrEmpty(brfId)) { throw new ArgumentNullException(nameof(brfId)); } var wait10 = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); driver.Navigate().GoToUrl(loginUrl); driver.WaitUntilDocumentReady(); var pid = driver.FindElement(By.Id("BankidLoginViewModel_PersonNumber")); //Changed dec 2019 from login_UserName pid.Clear(); pid.SendKeys(username); // Select BankID login var btn = driver.FindElement(By.XPath("//button[@type='submit' and contains(., 'BankID')]")); // Changed spring 2020 from By.CssSelector("form > button")); //Changed dec 2019 from By.Id("login_Login_Button")); btn.Click(); // Waiting for user to login // TODO: not sure what the doc looks like when choosing between roles... new WebDriverWait(driver, TimeSpan.FromMinutes(1)).Until(d => d.FindElements(By.Id("loginModal")).Any() == false); // We might have to select a role here - otherwise we'll be at portal main page if (!driver.Url.EndsWith("/Portalen")) //https://varbrf.sbc.se { var finder = By.XPath($"//a[text()='{brfId}']"); // Changed dec 2019 from "//input[@type='submit' and @value='{brfId}']"); new WebDriverWait(driver, TimeSpan.FromMinutes(1)).Until(WebDriverExtensions.ElementIsPresent(finder)); var element = driver.FindElement(finder); if (element == null) { throw new NotFoundException($"Text {brfId} not found"); } await Task.Delay(500); try { element.Click(); } catch (Exception ex) { throw; } } await Task.Delay(500); driver.WaitUntilDocumentReady(); }