水豚数据列表 Select 不可见

Capybara Datalist Select not visible

我有以下 HTML 片段:

<input type="text" id="manufacturer" list="manufacturers" placeholder="Search by manufacturer name or supplier code" class="form-control form-control-2-3" value="" name="manufacturer">


 <datalist id="manufacturers">
     <select>
      <div>
       <option value="Jaguar">AA</option>
       <div></div>
      </div>
      <div>
       <option value="Audi">AB</option>
       <div></div>
      </div>
     <div>
       <option value="Mercedes">AC</option>
       <div></div>
     </div>
     </select>
    </datalist>

这是一个下拉菜单,我想select其中一个选项。无论我尝试使用任何 find 命令或 select 函数。我总是得到同样的错误:

Selenium::WebDriver::Error::ElementNotVisibleError: element not visible: Element is not currently visible and may not be manipulated

有人对如何确定这些选项和 select 一个有什么建议吗?

谢谢。

您尝试执行的操作目前无法执行,因为它实际上不是下拉 select 元素。 选项元素实际上在页面上永远不可见,因为标准状态为 "In the rendering, the datalist element represents nothing and it, along with its children, should be hidden." - https://html.spec.whatwg.org/dev/form-elements.html#the-datalist-element 。相反,数据列表中的任何

fill_in("manufacturer", with: 'Jaguar')