簡體   English   中英

無法通過“可編輯復選框”選擇表中的元素

[英]Not able to select an element in a table by “editable-checkbox”

在以下情況下想尋求您的幫助:

我需要訪問一個表,選擇包含status ='GOO'的行,然后我需要單擊一個按鈕來激活該行的編輯,然后單擊復選框所在的最后一列的a(此復選框框負責將列中的值從False更改為true,反之亦然)

在函數中單擊我正在執行的按鈕:

    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”后面都有狀態代碼。 因此,這就是為什么我要從測試中接收狀態,然后將其直接傳遞到元素定位器。

我的問題/問題是...每次執行測試時,都可以單擊該按鈕進行編輯(位於表的第一列,並且與要單擊的復選框位於同一行),但對於復選框卻失敗:

“使用定位器找不到任何元素: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>

UPDATE

@Sanja的回答是99%正確,我必須這樣做才能解決問題:

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

根據代碼,您似乎要單擊跨度,而不是復選框。 為了單擊復選框,您需要選擇輸入元素:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM