Testing 如何在具有动态元素的文本区域中键入文本?

Testing 如何在具有动态元素的文本区域中键入文本?,testing,automated-tests,e2e-testing,testcafe,browser-automation,Testing,Automated Tests,E2e Testing,Testcafe,Browser Automation,我想在textarea中输入文本,但找不到元素,因为id是动态的,如果使用class,元素是可见的。这是元素的一部分,这是元素的一部分。 这是我写在剧本上的 let textArea=选择器('.block card list group item text card col-xs-12')。查找('textArea') 等待 .typeText(文本区域“Hai…”) 我得到一个错误: The specified selector does not match any element in

我想在textarea中输入文本,但找不到元素,因为id是动态的,如果使用class,元素是可见的。这是元素的一部分,这是元素的一部分。 这是我写在剧本上的

let textArea=选择器('.block card list group item text card col-xs-12')。查找('textArea')
等待
.typeText(文本区域“Hai…”)
我得到一个错误:

The specified selector does not match any element in the DOM tree.

> | Selector('.block-card list-group-item text-card col-xs-12')
  |   .find('textarea')
我也用

let textArea=Selector('.hwt container')。find('textArea')。withAttribute('class','text-card-text'))
还是一样

尝试使用该方法而不是withAttribute

更新:

下面是我的示例测试用例:

60986279.html

<div id="cardList" class="list-group">
<div id="1585" class="block-card list-group-item text card col-xs-12">
<div class="hwt-container">
<div class="hwt-backgdrop">
<textarea id="1585" maxlength="640" spellcheck="false" placeholder="Enter Text" style="overflow: hidden; break-word;" class="text-card-text maxlengthBadge form-control"></textarea>
</div>
</div>
</div>
</div>

我使用let textArea=wait Selector('.list group').find('.block card').find('.list group item.form group').find('div').find('.hwt container').find('textArea').hasClass('text-card-text-maxlengthBadge表单控件以自动调整hwt输入hwt内容的大小'),但出现错误:操作“选择器”参数错误:选择器应使用函数、CSS选择器字符串、另一个选择器、节点快照或选择器返回的承诺进行初始化,但已传递布尔值。对于造成的混淆,我深表歉意。我用一个示例测试用例更新了我的答案,它通过了。我尝试复制所描述的行为失败。如果我的示例在您的代码中不起作用,请使用您的完整标记更新我的示例。我在您的示例中遇到错误:1)与指定选择器匹配的元素不可见。我使用1.8.3版的testcafe运行我的示例,如下所示:
testcafe chrome 60986270.js
,测试通过。您可以(和我的示例)检查网页状态以及哪些元素可用。
import { Selector} from 'testcafe';

fixture('fixture')
    .page('file:///path/60986279.html');

test('test', async t => {
    let textArea = Selector('.block-card').find('textarea')
    await t.typeText(textArea, 'Hai...')
});