【问题标题】:Unable to select option from react-select drop down Robotframework无法从反应选择下拉机器人框架中选择选项
【发布时间】:2021-12-13 14:52:05
【问题描述】:

有一个名为“sampleType”的下拉菜单,其中有几个值“AB1、AB2、.. AB6”。

当我手动点击下拉菜单时,默认选择 AB1。

我需要根据用户输入选择其他值,即 AB2-AB6。

我在这里遇到了很多问题,但没有找到合适的。

下面是 HTML sn-p。

请帮助并提前致谢!

<div class="react-select" id="sampleType" role="presentation">
<div class="Select react-select has-outline has-value Select--single">
<input name="sampleType" type="hidden" value="AB1">
<div class="Select-control">
<span class="Select-multi-value-wrapper" id="react-select-sampleType--value" aria-label="Select Menu. AB1 selected.">
<div class="Select-value">
<span class="Select-value-label" role="option" aria-selected="true" id="react-select-sampleType--value-item">AB1</span>
</div>
<div aria-expanded="false" aria-owns="" aria-activedescendant="react-select-sampleType--value" aria-disabled="false" class="Select-input datagrid-row-actions" role="combobox" style="border: 0px none; width: 1px; display: inline-block;" tabindex="0"></div>
</span>
<span class="Select-arrow-zone">
<span class="Select-arrow"></span></span></div></div><div class="footer-height" role="alert"><div class="error"></div></div></div>

【问题讨论】:

  • 将您的代码试验和错误添加到问题中

标签: selenium selenium-webdriver robotframework


【解决方案1】:

从您的 sn-p 看来,您正在使用名称属性为“sampleType”的组合框?然后您可以实际输入所需的输入。它看起来像这样:

driver.find_element_by_name("sampleType").send_keys(valueFromUserInput)

您需要定位“输入”标签,并将输入(send_keys)发送给它

【讨论】:

  • 这很有帮助。我正在机器人框架中尝试它,我尝试使用 PressKeys,它失败了,但网页上没有任何操作。即使我手动打开它并输入键,它也不会过滤或获得匹配的值。
猜你喜欢
  • 2018-10-13
  • 2014-09-15
  • 2012-04-24
  • 1970-01-01
  • 2017-09-10
  • 2016-01-29
  • 2016-10-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多