当前位置: 代码迷 >> java >> 不选择时如何从组合框中选择
  详细解决方案

不选择时如何从组合框中选择

热度:56   发布时间:2023-07-16 17:42:41.0

我正在为某些网站创建一个自动测试,并且正在使用WebDriver,TestNG和用Java编写的代码,我需要从组合框中选择选项1,但是select元素不可见。

   Select element = new Select(driver.findElement(By.xpath("/html/body/div[1]/div/form/fieldset/span/span[1]/span/span/select")));
   element.selectByValue("1");

组合框的html代码是:

<span id="" class="selectboxit-container selectboxit-container" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="true" aria-owns="">
<span id="" class="selectboxit selectboxit-enabled selectboxit-btn selectboxit-open" name="c1" tabindex="0" unselectable="on" style="width: 157px;">
<span class="selectboxit-option-icon-container">
<i id="" class="selectboxit-option-icon selectboxit-container selectboxit-default-icon" unselectable="on"></i>
</span>
<span id="" class="selectboxit-text" unselectable="on" data-val="1" style="max-width: 81px;" aria-live="polite">Movité a ostatní</span>
<span id="" class="selectboxit-arrow-container" unselectable="on">
<i id="" class="selectboxit-arrow selectboxit-default-arrow" unselectable="on"></i>
</span>
</span>
<ul class="selectboxit-options selectboxit-list" tabindex="-1" style="min-width: 78.7667px; display: block; max-height: 62px; top: auto;" role="listbox" aria-hidden="false">
<li class="selectboxit-option selectboxit-option-first" data-disabled="false" data-val="2" data-id="0" role="option">
<a class="selectboxit-option-anchor">
</li>
<li class="selectboxit-option selectboxit-option-last selectboxit-selected selectboxit-focus" data-disabled="false" data-val="1" data-id="1" role="option" data-active="">
</ul>
</span>

有人可以建议我吗? 谢谢

网址链接: :

img: :

它的not Select元素不是下拉列表,可以在此处使用Select命令。我希望您可以通过模拟单击命令来尝试。

谢谢

  相关解决方案