• <bdo id='vddYS'></bdo><ul id='vddYS'></ul>
  • <i id='vddYS'><tr id='vddYS'><dt id='vddYS'><q id='vddYS'><span id='vddYS'><b id='vddYS'><form id='vddYS'><ins id='vddYS'></ins><ul id='vddYS'></ul><sub id='vddYS'></sub></form><legend id='vddYS'></legend><bdo id='vddYS'><pre id='vddYS'><center id='vddYS'></center></pre></bdo></b><th id='vddYS'></th></span></q></dt></tr></i><div id='vddYS'><tfoot id='vddYS'></tfoot><dl id='vddYS'><fieldset id='vddYS'></fieldset></dl></div>

    1. <tfoot id='vddYS'></tfoot>
      1. <small id='vddYS'></small><noframes id='vddYS'>

        <legend id='vddYS'><style id='vddYS'><dir id='vddYS'><q id='vddYS'></q></dir></style></legend>

        WebDriverWait 不等待我指定的元素

        WebDriverWait is not waiting for the element I specify(WebDriverWait 不等待我指定的元素)

          <tbody id='SRtEg'></tbody>

            <small id='SRtEg'></small><noframes id='SRtEg'>

            <legend id='SRtEg'><style id='SRtEg'><dir id='SRtEg'><q id='SRtEg'></q></dir></style></legend>
            <tfoot id='SRtEg'></tfoot>

            • <i id='SRtEg'><tr id='SRtEg'><dt id='SRtEg'><q id='SRtEg'><span id='SRtEg'><b id='SRtEg'><form id='SRtEg'><ins id='SRtEg'></ins><ul id='SRtEg'></ul><sub id='SRtEg'></sub></form><legend id='SRtEg'></legend><bdo id='SRtEg'><pre id='SRtEg'><center id='SRtEg'></center></pre></bdo></b><th id='SRtEg'></th></span></q></dt></tr></i><div id='SRtEg'><tfoot id='SRtEg'></tfoot><dl id='SRtEg'><fieldset id='SRtEg'></fieldset></dl></div>
                <bdo id='SRtEg'></bdo><ul id='SRtEg'></ul>
                • 本文介绍了WebDriverWait 不等待我指定的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图让我的代码在尝试从元素中获取文本之前等待元素出现.如果我单步执行允许元素时间出现的代码,它会按预期工作,但如果我在没有断点的情况下运行它,等待似乎会被忽略并引发异常.

                  I am trying to get my code to wait for an element to appear before trying to get the text from the element. If I step through the code allowing the element time to appear it works as expected, but if I run it without breakpoints the wait appears to be ignored and an exception is raised.

                  我不明白为什么它被忽略了?

                  I don't understand why it is being ignored?

                  WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                  IWebElement message = wait.Until(driver => driver.FindElement(By.ClassName("block-ui-message")));
                  string messageText = message.Text;
                  

                  推荐答案

                  作为替代方案,您可以为 ElementIsVisible() 引入 WebDriverWait,您可以使用以下 定位器策略:

                  As an alternative you can induce WebDriverWait for the ElementIsVisible() and you can use the following Locator Strategy:

                  string messageText = new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementIsVisible(By.ClassName("block-ui-message"))).GetAttribute("innerHTML");
                  

                  <小时>

                  DotNetSeleniumExtras.WaitHelpersnuget 一起使用:

                  不太清楚你所说的我需要的具体使用指令到底是什么意思.如果您使用的是 SeleniumExtrasWaitHelpers,您可以使用以下解决方案:


                  Using DotNetSeleniumExtras.WaitHelpers with nuget:

                  Not that super clear what exactly you meant by specific using directive I need. In-case you are using SeleniumExtras and WaitHelpers you can use the following solution:

                  string messageText = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("block-ui-message"))).GetAttribute("innerHTML");
                  

                  这篇关于WebDriverWait 不等待我指定的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)
                    <bdo id='Ol2Cz'></bdo><ul id='Ol2Cz'></ul>
                      <tbody id='Ol2Cz'></tbody>
                    <i id='Ol2Cz'><tr id='Ol2Cz'><dt id='Ol2Cz'><q id='Ol2Cz'><span id='Ol2Cz'><b id='Ol2Cz'><form id='Ol2Cz'><ins id='Ol2Cz'></ins><ul id='Ol2Cz'></ul><sub id='Ol2Cz'></sub></form><legend id='Ol2Cz'></legend><bdo id='Ol2Cz'><pre id='Ol2Cz'><center id='Ol2Cz'></center></pre></bdo></b><th id='Ol2Cz'></th></span></q></dt></tr></i><div id='Ol2Cz'><tfoot id='Ol2Cz'></tfoot><dl id='Ol2Cz'><fieldset id='Ol2Cz'></fieldset></dl></div>

                  • <legend id='Ol2Cz'><style id='Ol2Cz'><dir id='Ol2Cz'><q id='Ol2Cz'></q></dir></style></legend>

                        1. <tfoot id='Ol2Cz'></tfoot>

                            <small id='Ol2Cz'></small><noframes id='Ol2Cz'>