Primeng编辑表运行使用量角器恢复元素未找到错误

发布于 2025-02-12 04:54:24 字数 1326 浏览 1 评论 0原文

以下是我用于Primeng可编辑表的HTML代码,

<tr>
    <td *ngFor="let fields of header; let i=index;" pEditableColumn>
        <p-cellEditor>
            <ng-template pTemplate="input">
                <input id="edit-col-{{i}}" pInputText type="text"
                    [(ngModel)]="rows[fields.fieldId].data">
            </ng-template>
            <ng-template pTemplate="output">
                <div class="scrollable-div">
                    <span>
                        {{rows[fields.fieldId].data}}
                    </span>
            </div>
            </ng-template>
        </p-cellEditor>
    </td>
</tr>

这是我的量角代码,

    selectedElement = element(by.xpath('//tr[@id=\'new-row-1\']'));
    const eachCols = selectedElement.all(by.tagName('td'));

    eachCols.each(async (ele, index) => {

        //click element to view the edit box
        genericAction.clickButton(ele).then(async () => { 

        const inputElement = element(by.id(`edit-col-${index}`));
            await genericAction.setInputField(inputElement,"new data");
        });

    });

上面的代码单击正常,但是在提供输入时,请在使用以下错误来填充该值, *未找到使用定位器的元素:by(CSS选择器, [id =“ edit-col-0”]) 我不确定我缺少什么。

Following is my html code for primeng editable table,

<tr>
    <td *ngFor="let fields of header; let i=index;" pEditableColumn>
        <p-cellEditor>
            <ng-template pTemplate="input">
                <input id="edit-col-{{i}}" pInputText type="text"
                    [(ngModel)]="rows[fields.fieldId].data">
            </ng-template>
            <ng-template pTemplate="output">
                <div class="scrollable-div">
                    <span>
                        {{rows[fields.fieldId].data}}
                    </span>
            </div>
            </ng-template>
        </p-cellEditor>
    </td>
</tr>

And this is my protractor code,

    selectedElement = element(by.xpath('//tr[@id=\'new-row-1\']'));
    const eachCols = selectedElement.all(by.tagName('td'));

    eachCols.each(async (ele, index) => {

        //click element to view the edit box
        genericAction.clickButton(ele).then(async () => { 

        const inputElement = element(by.id(`edit-col-${index}`));
            await genericAction.setInputField(inputElement,"new data");
        });

    });

with the above code click is working fine, but while providing the input, getting the following error to fill the value, *No element found using locator: By(css selector, [id="edit-col-0"]) I am not sure what I am missing it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

琉璃梦幻 2025-02-19 04:54:24

索引没有填充。
由于我不使用量角器,所以我只能做出修复方法,但我的猜测是:

    $(eachCols).each(async (ele, index) => {

        //click element to view the edit box
        genericAction.clickButton(ele).then(async () => { 

            const inputElement = element(by.id('edit-col-' + index));
            await genericAction.setInputField(inputElement,"new data");
        });

    });

而且您也许可以按这样的行更改:

            await genericAction.setInputField($(inputElement),"new data");

The index is not filled.
As I'm not working with protractor, I can make only assumptions how to fix it but my guess would be this:

    $(eachCols).each(async (ele, index) => {

        //click element to view the edit box
        genericAction.clickButton(ele).then(async () => { 

            const inputElement = element(by.id('edit-col-' + index));
            await genericAction.setInputField(inputElement,"new data");
        });

    });

And you've perhaps to change the according line like this:

            await genericAction.setInputField($(inputElement),"new data");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文