javascript - 如何从下拉列表中选择具有 SELECT OPTION 标签的元素?
问题描述
我正在使用 WEBDRIVERIO 框架。我在这个 html 语法中有一个下拉菜单。我尝试使用 ID=question-3 来扩展它
之后,我使用 SELECT 按选项、值、文本尝试了所有选项。但由于它显然不是 SELECT DROPDOWN,所以没有任何效果。我尝试根据输入或标签选项单击定位器,但收到“元素不可见”错误消息。
<div id="question-3" class="question ">
<div class="single-dropdown">
<input type="text" name="input-3" class="js-single-selection" placeholder="gender" data-question-id="3" data-index="3" readonly="" style="width: 77px;">
<div class="single-select-container" style="display: none;">
<div class="single-select-item" data-image="">
<label for="option-0-3" data-open="exampleModal1" class="option-0-3-modal">man</label>
<input type="checkbox" id="option-0-3" data-answer-type="single" data-question-id="3" value="man" data-index="3">
</div>
<div class="single-select-item checked" data-image="">
<label for="option-1-3" data-open="exampleModal1" class="option-1-3-modal">woman</label>
<input type="checkbox" id="option-1-3" data-answer-type="single" data-question-id="3" value="woman" data-index="3">
</div>
</div>
</div>
.</div>
解决方案
由于 html 显示输入标签。我建议:
1. type the value in that input box (placeholder="gender")
2. wait for options to appear (Label tag)
3. click the appeared item.(Appeared label)
此外,如果您的方案失败,请提供失败的堆栈跟踪。
推荐阅读
- c++ - 基类能否知道派生类是否覆盖了虚方法?
- python - 一个模块已经安装,Python 可以将它导入 dist-packages 文件夹,但不能在其他任何地方导入
- c# - 如何在 AppData\Roaming 而不是 AppData\Local\Packages 下保存数据
- python - 如何使用 Python 连接到受保护的 Sqlite3 数据库
- mysql - MYSQL#1064 - 你的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以了解在附近使用的正确语法
- mysql - 通过删除重复项添加唯一约束
- r - 闪亮的服务器:应用程序无法在 AWS 上启动
- git - 如何将 hexo 移至另一台计算机?
- ios - UIWebView 委托不会在自定义类中触发
- python - 如何将 Bokeh 与 Angular 4 集成?