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

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

    • <bdo id='Mipsd'></bdo><ul id='Mipsd'></ul>

      <tfoot id='Mipsd'></tfoot>
    1. <i id='Mipsd'><tr id='Mipsd'><dt id='Mipsd'><q id='Mipsd'><span id='Mipsd'><b id='Mipsd'><form id='Mipsd'><ins id='Mipsd'></ins><ul id='Mipsd'></ul><sub id='Mipsd'></sub></form><legend id='Mipsd'></legend><bdo id='Mipsd'><pre id='Mipsd'><center id='Mipsd'></center></pre></bdo></b><th id='Mipsd'></th></span></q></dt></tr></i><div id='Mipsd'><tfoot id='Mipsd'></tfoot><dl id='Mipsd'><fieldset id='Mipsd'></fieldset></dl></div>
      1. Selenium Select - 通过部分文本选择下拉选项

        时间:2023-06-27
        <tfoot id='oHtN4'></tfoot>

          <bdo id='oHtN4'></bdo><ul id='oHtN4'></ul>

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

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

              • <legend id='oHtN4'><style id='oHtN4'><dir id='oHtN4'><q id='oHtN4'></q></dir></style></legend>
                • 本文介绍了Selenium Select - 通过部分文本选择下拉选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  类 Selenium Select 有 3 种不同的选项选择方法:

                  The class Selenium Select has 3 methods of different option selection:

                  1. 选择索引
                  2. 按值选择
                  3. selectByVisibleText

                  现在,我有一种情况,我想通过一些文本选择一个选项,该文本部分出现在选项可见文本之一中(不想让自己暴露于整个文本中的更改).

                  Now, I have a situation where I want to select an option by some text that partially appear in one of the options visible text (don't want to expose myself to changes in the WHOLE text).

                  例如:

                  <option value="0" label="not-intresting">VERY-LONG-TEXT-THAT-I-NEED-TO-SELECT-DOLLAR</option>
                  

                  我只想通过提供DOLLAR"来选择此选项,例如:

                  And i want to select this option only by providing the "DOLLAR", something like:

                  select.selectByPartOfVisibleText("DOLLAR") 
                  

                  您将如何有效地实施它?

                  How would you implement it effectively?

                  推荐答案

                  你可以试试这样的逻辑,希望对你有帮助

                  You can try a logic like this hope this helps

                  List <WebElements> optionsInnerText= driver.findElements(By.tagName("option"));
                  for(WebElement text: optionsInnerText){
                      String textContent = text.getAttribute("textContent");
                      if(textContent.toLowerCase.contains(expectedText.toLowerCase))
                             select.selectByPartOfVisibleText(expectedText);
                      }
                  }
                  

                  这篇关于Selenium Select - 通过部分文本选择下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:禁用 Chrome 通知 (Selenium) 下一篇:WebDriverException: java.net.ConnectException: Failed to con

                  相关文章

                • <legend id='BIYkB'><style id='BIYkB'><dir id='BIYkB'><q id='BIYkB'></q></dir></style></legend>
                  <tfoot id='BIYkB'></tfoot>

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

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