为什么我的登录无法使用流畅的等待而失败,而是尝试进行显式尝试却没有用?

时间:2019-10-24 02:43:46

标签: c# selenium-webdriver

我正在尝试登录浏览器,我尝试了显式等待,即Expectedconditions.elementisvisible,但这没有用,所以我走了fluentwaits的路线。刚开始fluent1有效,然后第二次fuentwait无效。在第三次运行中,两者现在都不起作用

public void loginVT(IWebDriver driver)
        {

            _regRep = new UserRegRep(driver);
            driver.Navigate().GoToUrl(_regRep.AppURL);

            DefaultWait<IWebDriver> fluentWait = new DefaultWait<IWebDriver>(driver);
            fluentWait.Timeout = TimeSpan.FromSeconds(30);
            fluentWait.PollingInterval = TimeSpan.FromMilliseconds(3000);
            fluentWait.IgnoreExceptionTypes(typeof(NoSuchElementException));
            IWebElement searchResult = fluentWait.Until(x => x.FindElement(By.Id("Email")));


            _regRep.Email.SendKeys("test@hotmail.com");
            String strFile = System.IO.File.ReadAllText("password.csv");
            _regRep.Password.SendKeys(strFile);
            _regRep.LogInButton.Click();

            //when the user icon is displayed, we have successfully logged in
             DefaultWait<IWebDriver> fluentWait1 = new DefaultWait<IWebDriver>(driver);
            fluentWait1.Timeout = TimeSpan.FromSeconds(30);
            fluentWait1.PollingInterval = TimeSpan.FromMilliseconds(3000);
            fluentWait1.IgnoreExceptionTypes(typeof(NoSuchElementException));
            IWebElement searchResult1 = fluentWait1.Until(x => x.FindElement(By.XPath("//span[text()='User']")));

}

0 个答案:

没有答案