代码之家  ›  专栏  ›  技术社区  ›  Alexandre

无法通过“可编辑复选框”选择表中的元素

  •  0
  • Alexandre  · 技术社区  · 7 年前

    我需要访问一个表,选择包含status='GOO'的行,然后 我需要单击一个按钮来激活对此行的编辑,然后

    在函数中单击我正在执行的按钮:

        function changeConformStatus(statusCode){
             element(by.id('btnEdit-US.'+statusCode)).click(); 
             browser.sleep(500);
        }
    

             element(by.css('[editable-checkbox="scopeValue.getConformMapping(scopeValue.getDataRow('+'US.'+statusCode+')).conform"]')).click();
             element(by.id('btnSubmit-US.'+statusCode)).click();
    

    所有元素的状态代码都在“US”之后,所以我从测试接收状态,然后直接将其传递给元素定位器。

    “使用locator:By(css选择器,[editable checkbox=”scopeValue.getConformMapping(scopeValue.getDataRow(US.GOO)).conform“])未找到元素”

    所以。。那么,我如何单击此复选框?

    HTML格式:

    <table id="datatableDir" class="table table-hover  table-bordered table-striped dataTable no-footer" style="width: 100%" role="grid" aria-describedby="datatableDir_info">
    <thead>...</thead>
    <tbody>
    <tr role="row" class="odd">
        <td id="2-4" class="ng-scope">
            <span editable-checkbox="scopeValue.getConformMapping(scopeValue.getDataRow('US.GOO')).conform" e-name="conform" e-form="scopeValue.rowforms['US.GOO']" e-required="" class="ng-scope ng-binding editable editable-hide">false</span>
            <span class="editable-wrap editable-checkbox ng-scope">
                <span class="editable-controls">
                    <input type="checkbox" name="conform" required="required" class="editable-input ng-touched ng-dirty ng-valid-parse ng-not-empty ng-valid ng-valid-required" ng-model="$data" style="">
                    <div class="editable-error ng-binding ng-hide" ng-show="$error" ng-bind="$error" style=""></div>
                </span>
            </span>
        </td>
    </tr>
    </tbody>
    </table>
    

    @Sanja的答案是99%正确,我必须这样做才能解决问题:

    element(by.xpath("//*[@editable-checkbox=\"scopeValue.getConformMapping(scopeValue.getDataRow("+'\'US.'+statusCode+"\')).conform\"]/../span/span/input")).click();
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Sanja Paskova    7 年前

    根据代码,您似乎要单击范围,而不是复选框。

    element(by.xpath(".//[@editable-checkbox='scopeValue.getConformMapping(scopeValue.getDataRow('+'US.'+statusCode+')).conform/../span[1]/span/input")).click()