简体   繁体   中英

C# Selenium Chrome Driver isnt waiting

my ChromeDriver doesnt waits for imlicityWaits and only waits for ElementExists in ExplicitWaits all others throw Errors. I cannot use other ExpectedConditions then ElementExits.

    public async Task LoginPage()
    {
        await Task.Run(() =>
        {
            driver.Navigate().GoToUrl(@"https://www.google.de/");

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            Console.WriteLine("10 Sec");

            new WebDriverWait(Globals.webDriverChrome.driver, TimeSpan.FromSeconds(30)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='gbqfbb']")));
            Console.WriteLine("Hahahahha i did the job");

        });
    }

Check this element you are referring by ID, maybe it is loaded before.

public static void Wait(int seconds)
        {
            DriverContext.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(seconds);
            new WebDriverWait(DriverContext.Driver, TimeSpan.FromSeconds(seconds)).Until(ExpectedConditions.TextToBePresentInElement(DriverContext.Driver.FindElement(By.Id("MyAccountLink")), "My Account"));
        }

I have been using this function for myself, just find finding element by ID

Fixed it. Nuget Fody/Costura add-in was the problem. Uninstalled, now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM