selenium - 我无法使用 selenium 将密钥发送到输入元素。也试过用js
问题描述
<div class=" css-0">
<div class="css-zcohbc-singleValue">General</div>
</div>
<div class="css-0">
<div class="" style="display: inline-block;">
<input autocapitalize="none" autocomplete="off" autocorrect="off" id="react-select-3-input" spellcheck="false" tabindex="0" type="text" aria-autocomplete="list" value="" style="box-sizing: content-box; width: 2px; background: 0px center; border: 0px; font-size: inherit; opacity: 1; outline: 0px; padding: 0px; color: inherit;">
<div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 14px; font-family: Roboto, "Helvetica Neue", Arial, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;">
</div>
</div>
</div>
</div>
我需要将密钥发送到输入标签。
WebElement elmnt = driver.findElement(By.xpath("//input[@aria-autocomplete='list']"));
尝试使用普通的 Selinium,
elmnt.click();
elmnt.sendKeys("Text");
还尝试用 JS 点击并发送密钥
JavascriptExecutor js= (JavascriptExecutor) driver;
js.executeScripts("arguments[0].click();",elmnt);
elmnt.sendKeys("Text");
任何人都可以建议,我可能会错过什么?
解决方案
推荐阅读
- python - 对python中的变量感到困惑。python如何使用变量?
- ios - UITableView 动画调整大小问题
- javascript - ajax调用成功后添加文本区域
- json - 服务器没有从远程 REST API 获取所有 JSON
- etl - 如何在 DataStage 中按照我的意愿(自定义)制作 XPATH 格式?
- javascript - Mocha - 无法实现 TestFunction 接口方法
- python - TensorFlow 多线程推理比单线程推理慢
- assembly - 如何在不使用标签的情况下跳转到特定行?
- python - 使用 pyodbc 时,SQL Server DateTimeOffset 将 tz 感知日期时间的偏移量更改为系统偏移量
- firebase - Flutter:Java 使用或覆盖已弃用的 API