简体   繁体   English

C# Selenium Chrome 驱动程序未等待

[英]C# Selenium Chrome Driver isnt waiting

my ChromeDriver doesnt waits for imlicityWaits and only waits for ElementExists in ExplicitWaits all others throw Errors.我的 ChromeDriver 不等待 imlicityWaits 并且只等待 ExplicitWaits 中的 ElementExists 所有其他人都会抛出错误。 I cannot use other ExpectedConditions then ElementExits.我不能使用其他 ExpectedConditions 然后 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.检查您通过 ID 引用的此元素,也许它之前已加载。

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我一直在为自己使用这个 function,只需通过 ID 查找元素

Fixed it.解决它。 Nuget Fody/Costura add-in was the problem. Nuget Fody/Costura 插件是问题所在。 Uninstalled, now it works.卸载了,现在可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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