Testing 选择选择器的正确方法

Testing 选择选择器的正确方法,testing,automated-tests,e2e-testing,testcafe,browser-automation,Testing,Automated Tests,E2e Testing,Testcafe,Browser Automation,在我的TestCafe脚本中,我尝试选择3个输入。它们是: 科普舍赫(奥恩·索克尔) 钾云母 钾云母 我在脚本中使用了: 等待t .typeText(选择器('div')。withText('Korpushöhe')。查找('input'),'1200',{replace:true}) .typeText(选择器('div')。withText('Korpusbreite')。查找('input'),'1400',{replace:true}) .typeText(选择器('div')。wi

在我的TestCafe脚本中,我尝试选择3个输入。它们是:


科普舍赫(奥恩·索克尔)
钾云母
钾云母
我在脚本中使用了:

等待t
.typeText(选择器('div')。withText('Korpushöhe')。查找('input'),'1200',{replace:true})
.typeText(选择器('div')。withText('Korpusbreite')。查找('input'),'1400',{replace:true})
.typeText(选择器('div')。withText('Korpustiefe')。查找('input'),'400',{replace:true});

但如果我运行此脚本,浏览器将在第一个字段中键入文本3次。这令人困惑。我做错了什么?

尝试使用“兄弟姐妹”


尝试使用“兄弟姐妹”

await t
    .typeText(Selector('div').withText('Korpushöhe').sibling('input'), '1200', {replace: true})
    .typeText(Selector('div').withText('Korpusbreite').sibling('input'), '1400', {replace: true})
    .typeText(Selector('div').withText('Korpustiefe').sibling('input'), '400', {replace: true})