无法从下拉Robotframework中选择项目

时间:2018-05-03 06:58:24

标签: selenium selenium-webdriver robotframework robotframework-ide

我试图找到下拉菜单以选择值但获得异常

ElementNotInteractableException: Message: Element <option> could not be scrolled into view

我使用以下声明

Select From List by Value    xpath=//select[@id="appgroups"]    2

请参阅我的图片以供参考。请帮助我![enter image description here] 1

2 个答案:

答案 0 :(得分:0)

请检查我的html代码如下(我的问题无法附加,因为代码太长,不允许)

<div id="dlg_crud" class="modal fade bs-example-modal-static" tabindex="-1" role="dialog" data-backdrop="static">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
          <div class="modal-header">
              <button aria-hidden="true" data-dismiss="modal" class="close" type="button">&times;</button>
              <h4 class="modal-title" id="dlg_crud_title"></h4>
          </div>
          <div class="modal-body">
            <form id="frm_crud" class="form-horizontal form-margin">
            <input type="hidden" id="task" value="">
              <div class="row">
                <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Mã ứng dụng:</label>
                                            <div class="col-sm-8">
                                                <input class="crud form-control input-xs" type="text" id="appcode" name="appcode" maxlength="30"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Nhóm ứng dụng:</label>
                                            <div class="col-sm-8">
                                                <select id="appgroups" name="appgroups" class="crud form-control input-sm" >
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">SIBS:</label>
                                            <div class="col-sm-8">
                                                <select id="sibstypes" name="sibstypes" class="crud form-control input-sm" >
                                                    <option value="1"><%=Constants.APP_SIBS%></option>
                                                    <option value="2"><%=Constants.APP_NONSIBS%></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Mô tả:</label>
                                            <div class="col-sm-8">
                                                <input class="crud form-control input-xs" type="text" id="appdesc" name="appdesc" maxlength="500"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Ứng dụng gom gộp:</label>
                                            <div class="col-sm-8">
                                                <select id="appagg" name="appagg" class="crud form-control input-xs">
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Đường dẫn ứng dụng:</label>
                                            <div class="col-sm-8">
                                                <input class="crud form-control input-xs" type="text" id="weblink" name="weblink" maxlength="200"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Mã phần mềm:</label>
                                            <div class="col-sm-8">
                                                <input class="crud form-control input-xs" type="text" id="swcode" name="swcode" maxlength="30"/>
                                            </div>
                                        </div>
                                </div>
                                <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Tên ứng dụng:</label>
                                            <div class="col-sm-8">
                                                <input class="crud form-control input-xs" type="text" id="appname" name="appname" maxlength="200"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Loại ứng dụng:</label>
                                            <div class="col-sm-8">
                                                <select id="apptypes" name="apptypes" class="crud form-control input-sm" >
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Trạng thái:</label>
                                            <div class="col-sm-8">
                                                <select id="statuses" name="statuses" class="crud form-control input-sm" >
                                                    <option value="1"><%=Constants.APP_ACTIVE%></option>
                                                    <option value="0"><%=Constants.APP_INACTIVE%></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Nhóm xử lý:</label>
                                            <div class="col-sm-8">
                                                <select id="actids" name="actids" multiple="multiple" class="crud form-control input-xs">
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left"></label>
                                            <div class="col-sm-8">
                                                <div class="ckbox ckbox-primary cb-form">
                                                    <input type="checkbox" name="multiusr" id="multiusr" />
                                                    <label for="multiusr" class="text-danger" style="padding-top: 10px;">Sử dụng nhiều user/nhóm quyền</label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label align-left">Mật khẩu mặc định:</label>
                                            <div class="col-sm-8">
                                                <input class="crud form-control input-xs" type="text" id="defpass" name="defpass" maxlength="100"/>
                                            </div>
                                        </div>
                                </div>  
                </div>
              </form>
          </div>
          <div class="modal-footer">                
                <% if (Utils.checkSubMenu(subfunclist, "create") || Utils.checkSubMenu(subfunclist, "update")) { %>
                <button type="button" id="btnSubmit" class="btn btn-default btn-xs"></button>
                <% } %>
                <button type="button" data-dismiss="modal" class="btn btn-default btn-xs"><i class="fa fa-times"></i> Đóng</button>                 
          </div>
      </div>
    </div>
</div>

答案 1 :(得分:-1)

您可以使用此代码选择下拉列表

import org.openqa.selenium.support.ui.Select;

Select drp = new Select(driver.findElement(By.name("appgroups")));
drp.selectByVisibleText("your value here");