【发布时间】:2020-02-05 18:56:51
【问题描述】:
我正在使用 TestCafe 来测试基于 Wicket 框架的 Web 应用程序的自动化。我尝试在文本输入字段中输入文本……嗯,实际上它是一个下拉列表,其中出现了一个文本输入字段,以便用户可以搜索某些代码。 HTML 片段如下: HTML fragment
这是相应的截图(“001”上方的文本字段): Text input field with dropdown
用户可以输入一些字符,下面的列表会被自动过滤(我是手动完成的): Text input field with some text
我的 TestCafe 测试尝试这样做:
.click( productcodeList )
.expect( productcodeInputField.visible ).ok()
.click( productcodeInputField )
.typeText( productcodeInputField, 'ABW' )
即 单击下拉列表。 假设文本输入字段现在可见(工作正常)。 单击文本输入字段(这应该不是必需的,因为 typeText() 无论如何都应该这样做)。 在文本输入字段中输入文本“ABW”==> 这不起作用。 我确信我的选择器工作正常,因为断言(预期)是成功的,并且当我在第二次单击(在文本输入字段上)后调试测试运行时,我看到以下内容: TestCafe screenshot IE。光标直接在文本字段上,但不知何故TestCafe无法将文本写入该字段。
一些附加信息:输入字段的选择器创建如下:
productcodeInputField = Selector('span').withAttribute('class', /select2-dropdown.*/ ).child('span').withAttribute('class', /select2-search.*/ ).child('input').withAttribute('class', 'select2-search__field' );
更多信息:我在同一页面上使用相同的逻辑:
kurzbezeichnungField = Selector('input').withAttribute('name', /.*aeAbbreviation.*/);
...
await t.click( kurzbezeichnungField )
.typeText( kurzbezeichnungField, 'xxxWWW' )
这很好用。 Node.js 版本:v10.16.3 测试咖啡馆版本:1.5.0
【问题讨论】:
-
我不认为您可以共享用于与此输入字段交互的 CSS 选择器(或 XPath,无论您选择什么)?其他一切看起来都很好,所以......它确实有点抓不住稻草,但它可能会对此有所了解。
-
@AJC24:我对同一页面上的输入字段使用相同的逻辑...请参阅上面的其他信息。
标签: testing e2e-testing testcafe web-testing html-input