赛普拉斯 - AG网格表:命令类型()失去单元格的焦点

发布于 2025-01-19 11:01:38 字数 933 浏览 3 评论 0原文

我有以下问题:

我想使用“type()”在单元格中输入一个值。 我的猜测是,输入值时该单元格的焦点会丢失。

由于焦点丢失在每个字母上,并且命令“type()”可能会单击回单元格,因此最后一个字母会突出显示并替换为下一个字母。 结果如下: 时间 e s t

尝试使用命令“wait()”和“focus()”失败。

也许有可能减慢值的自动输入速度,

我很好奇您的意见和经验。

非常感谢

AG-Grid Cell 代码:

<div comp-id="1" class="ag-cell ag-cell-normal-height ag-cell-value ag-cell-inline-editing ag-cell-range-selected ag-cell-range-selected-1 ag-cell-range-single-cell" tabindex="-1" role="gridcell" aria-colindex="1" col-id="column" unselectable="on" style="left: 0px; width: 150px;">t</div>

Cell 截图: 输入图片此处描述

赛普拉斯命令:

cy.get('div[row-id="1553c463-0c87-4cc4-a672-89090c6f2cb9"]').should('exist').find('div[col-id="column"]').should('be.visible').click().type('Test{enter}');

I have the following problem:

I want to enter a value into the cell with 'type()'.
My guess is that the focus on this cell is lost when entering the value.

Due to the fact that the focus is lost on each letter and the command 'type()' probably clicks back into the cell, the last letter is highlighted and replaced with the next letter.
The result looks like this:
T
e
s
t

The attempt with the commands 'wait()' and 'focus()' failed.

Maybe there is a possibility to slow down the automated entering of the values

I am curious about your opinion and experiences.

Thanks a lot

AG-Grid Cell Code:

<div comp-id="1" class="ag-cell ag-cell-normal-height ag-cell-value ag-cell-inline-editing ag-cell-range-selected ag-cell-range-selected-1 ag-cell-range-single-cell" tabindex="-1" role="gridcell" aria-colindex="1" col-id="column" unselectable="on" style="left: 0px; width: 150px;">t</div>

Screenshot of Cell:
enter image description here

Cypress Command:

cy.get('div[row-id="1553c463-0c87-4cc4-a672-89090c6f2cb9"]').should('exist').find('div[col-id="column"]').should('be.visible').click().type('Test{enter}');

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

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

发布评论

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

评论(2

趴在窗边数星星i 2025-01-26 11:01:38

您询问了减慢价值观的问题。

您是否查看过文档Aruments - 选项

延迟 - 每次按键后延迟

.type('Test{enter}', {delay:100})

另一种尝试方法是 realType()

它在内部采用了与 Cypress .type() 不同的方法

cy.get('div[row-id="1553c463-0c87-4cc4-a672-89090c6f2cb9"] div[col-id="column"]')
  .should('be.visible')
  .focus();
cy.realType("some text {enter}"); // type into focused field

You asked about slowing down the values.

Did you look at the docs Aruments - options

delay - Delay after each keypress

.type('Test{enter}', {delay:100})

Another way to try is realType().

It takes a different approach internally to Cypress .type()

cy.get('div[row-id="1553c463-0c87-4cc4-a672-89090c6f2cb9"] div[col-id="column"]')
  .should('be.visible')
  .focus();
cy.realType("some text {enter}"); // type into focused field
初吻给了烟 2025-01-26 11:01:38

这个功能可以通过小调整来解决我的问题吗?

function setDataIntoCell(): void {
    const rowNode = this.gridOptions.api.getRowNode('1');
    rowNode.setDataValue('column', 'Test');
}

错误:
无法读取未定义的属性(读取“网格”)

Could this function, with small adjustment be the solution to my problem?

function setDataIntoCell(): void {
    const rowNode = this.gridOptions.api.getRowNode('1');
    rowNode.setDataValue('column', 'Test');
}

Error:
Cannot read properties of undefined (reading 'gridOptions')

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