【问题标题】:How select a drop down but element type is input using Robot Framework如何选择下拉菜单但使用 Robot Framework 输入元素类型
【发布时间】:2018-08-23 19:12:53
【问题描述】:

我目前正在使用机器人框架,并且有一个使用 mdbootstrap 作为前端的项目。 但是,我面临的问题是他们的下拉选择元素使用输入作为类型。

<input type="text" class="select-dropdown" readonly="true" data-activates="select-options-0c5c119c-fe7f-4c45-8db9-5af047606d66" value="Choose your option" xpath="1">
<ul id="select-options-0c5c119c-fe7f-4c45-8db9-5af047606d66" class="dropdown-content select-dropdown" style="width: 427.038px; position: absolute; top: 0px; left: 0px; opacity: 1; display: none;" xpath="1"><li class="disabled"><span class="filtrable">Choose your option</span></li><li class="active"><span class="filtrable">Option 1</span></li><li class=""><span class="filtrable">Option 2</span></li><li class=""><span class="filtrable">Option 3</span></li></ul>
<select class="mdb-select initialized" style="" xpath="1">
                    <option value="" disabled="" selected="">Choose your option</option>
                    <option value="1">Option 1</option>
                    <option value="2">Option 2</option>
                    <option value="3">Option 3</option>
                </select>

所以我想问一下那种下拉类型怎么选?

我试过了:

  • 直接选择类“mdb-select initialized”但会抛出错误 element not found
  • 另外,尝试先单击下拉元素以激活该选项,但结果相同。

有人对此有解决方案或方法吗?

【问题讨论】:

    标签: python selenium automation robotframework selenium2library


    【解决方案1】:

    顺便说一句,您可以使用 Xpath 作为选择值的定位器。 但我建议让您的开发团队设置 ID 或名称,因为这样可以让您更轻松地从此下拉列表中选择值。

    select from list by value  xpath=/html/body/select      2
    

    【讨论】:

    • 如果我问开发者在哪里设置 ID?在 还是在选择类型中?因为当我直接选择选择类型 '
    • 输入选择类型。只需设置此标签的名称即可。
    猜你喜欢
    • 2019-11-17
    • 1970-01-01
    • 1970-01-01
    • 2015-08-07
    • 2020-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多