<div class="Select form-control undefined Select--single is-searchable has-value"><input name="deal.listdealasset[0].acacode" type="hidden" value="NEWCAR"><div class="Select-control"><span class="Select-multi-value-wrapper" id="react-select-3--value"><div class="Select-value"><span class="Select-value-label" id="react-select-3--value-item" role="option" aria-selected="true">New</span></div><div class="Select-input" 我正在尝试从下拉列表中选择一个值,但它的html标签不是选择的。我尝试了各种选择但没有工作。WebElement optionsList = driver.findElement(By.xpath("//span[contains(@class, 'Select-multi-value-wrapper')]"));List<WebElement> options = optionsList.findElements(By.xpath("//span[contains(@class, 'Select-value-label')]"));options.get(0).click();我想从下拉列表中选择新值。[ 在此输入图像描述]我在执行时遇到错误 - 元素无法滚动到视图中以下是该页面的HTML代码 -<div class="Select form-control undefined Select--single is-searchable has-value"> <input name="deal.listdealasset[0].acacode" type="hidden" value="NEWCAR"> <div class="Select-control"> <span class="Select-multi-value-wrapper" id="react-select-3--value"> <div class="Select-value"><span class="Select-value-label" id="react-select-3--value-item" role="option" aria-selected="true">New</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-haspopup="false" aria-activedescendant="react-select-3--value" aria-owns="" style="width: 19px; box-sizing: content-box;" value="" data-rxName="deal.listdealasset[0].acacode"> <div style="left: 0px; top: 0px; height: 0px; text-transform: none; letter-spacing: normal; overflow: scroll; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-style: normal; font-weight: 400; white-space: pre; visibility: hidden; position: absolute;"></div> </div> </span> <span class="Select-arrow-zone"><span class="Select-arrow"></span></span> </div></div>
4 回答
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
由于你得到的元素错误无法滚动到视图中。您应该尝试使用JavascriptExecutor进行滚动。
这种方式允许您水平/垂直((JavaScriptExecutor)driver).executeScript("scroll(0,200)")滚动页面 - 仅垂直滚动200像素
2。使元素成为焦点
((JavaScriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", element);
添加回答
举报
0/150
提交
取消