【发布时间】:2018-01-29 07:25:58
【问题描述】:
我无法将密钥发送到可搜索的下拉列表。我可以使用以下方法展开下拉列表:
(//*/label[contains(text(),'Country of company registration')]/following-sibling::div//span[3]/span).click();
但是当我尝试向搜索字段发送一些键时,我得到:
org.openqa.selenium.ElementNotInteractableException: Element <div class="Select-input"> is not reachable by keyboard
我用于搜索字段“Select-input”的 Xpath 是:
//*/label[contains(text(),'Country of company registration')]/following-sibling::div//span/div[2]
我也尝试将文本发送到“选择值”,但我收到了类似的错误。 “选择值”的 Xpath 是:
//*/label[contains(text(),'Country of company registration')]/following-sibling::div//span/div[1]
完整对象:
<div class="form-group">
<label class=" form-control-label" for="countryCode">Country of company registration</label>
<div class="Select Select--single is-clearable is-searchable has-value">
<div class="Select-control">
<span id="react-select-12--value" class="Select-multi-value-wrapper">
<div class="Select-value">
<span id="react-select-12--value-item" class="Select-value-label" role="option" aria-selected="true">United Kingdom</span>
</div>
<div class="Select-input" style="display: inline-block;">
<style>input#undefined::-ms-clear {display: none;}</style>
<input role="combobox" aria-expanded="false" aria-owns="" aria-haspopup="false" aria-activedescendant="react-select-12--value" value="" style="width: 19px; box-sizing: content-box;"/>
<div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 16px; font-family: "Larsseit",sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;"/>
</div>
</span>
<span class="Select-clear-zone" title="Clear value" aria-label="Clear value">
<span class="Select-clear">×</span>
</span>
<span class="Select-arrow-zone">
<span class="Select-arrow"/>
</span>
</div>
</div>
</div>
*为格式化道歉。
编辑:我不相信我的问题与建议的问题重复。我已经进行了漫长的等待和明确的等待,以确保下拉菜单已扩展。我认为问题可能是由于下拉列表的动态性质,因此无法获得准确的 xpath。这只是一个猜测。谢谢。
【问题讨论】:
-
我不相信我的问题与建议的问题重复。我已经进行了漫长的等待和明确的等待,以确保下拉菜单已扩展。我认为问题可能是由于下拉列表的动态性质,因此无法获得准确的 xpath。这只是一个猜测。谢谢。
-
你想
sendKeys()做什么? -
你为什么要把你的密钥发送给?我相信文本应该出现的真正元素不是 div。尝试将键发送到 元素。你能发一个网站链接吗?