• <legend id='8V4ld'><style id='8V4ld'><dir id='8V4ld'><q id='8V4ld'></q></dir></style></legend>

      <small id='8V4ld'></small><noframes id='8V4ld'>

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

      <tfoot id='8V4ld'></tfoot>
      1. Selenium Select - 通过部分文本选择下拉选项

        时间:2023-09-28
        <legend id='UkwNR'><style id='UkwNR'><dir id='UkwNR'><q id='UkwNR'></q></dir></style></legend>
        1. <small id='UkwNR'></small><noframes id='UkwNR'>

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

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

                <tfoot id='UkwNR'></tfoot>
                  <tbody id='UkwNR'></tbody>

                  本文介绍了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 - 通过部分文本选择下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

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

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

                  1. <legend id='Zcshw'><style id='Zcshw'><dir id='Zcshw'><q id='Zcshw'></q></dir></style></legend>
                    <i id='Zcshw'><tr id='Zcshw'><dt id='Zcshw'><q id='Zcshw'><span id='Zcshw'><b id='Zcshw'><form id='Zcshw'><ins id='Zcshw'></ins><ul id='Zcshw'></ul><sub id='Zcshw'></sub></form><legend id='Zcshw'></legend><bdo id='Zcshw'><pre id='Zcshw'><center id='Zcshw'></center></pre></bdo></b><th id='Zcshw'></th></span></q></dt></tr></i><div id='Zcshw'><tfoot id='Zcshw'></tfoot><dl id='Zcshw'><fieldset id='Zcshw'></fieldset></dl></div>

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