无法在 "Type to search dropdown" 中键入文本,这是使用 testcafe 的反应组件
Unable to type text in a "Type to search dropdown" which is a react component using testcafe
无法在反应组件 "Type to search dropdown" 中输入文本。我可以单击该组件,但无法在其中键入任何文本。
下面是示例代码。
import { Selector } from 'testcafe';
test('Select option', async t => {
const dropdown = Selector('.section')
.find('.Select.is-clearable.is-searchable.Select--multi')
.find('.Select-control')
.find('.Select-placeholder')
.withText('Select...');
await t.click(dropdown);
await t.typeText(dropdown, 'abc'); // unable to pass text 'abc'
await t.wait(3000);
});
使用类似组件的示例站点 http://jedwatson.github.io/react-select/
const dropdown = Selector('.section')
.find('.Select.is-clearable.is-searchable.Select--multi')
.find('.Select-control')
.find('.Select-placeholder')
.withText('Select...');
const inputField = dropdown
.sibling('.Select-input')
.find('input');
await t
// wait until element is visible on the screen
.expect(dropdown.with({visibilityCheck: true}).exists).ok({timeout: 5000})
// access the element via the mouse (will fire the mouse event onMouseEnter)
.hover(dropdown)
.click(dropdown)
.typeText(inputField, 'abc');
无法在反应组件 "Type to search dropdown" 中输入文本。我可以单击该组件,但无法在其中键入任何文本。 下面是示例代码。
import { Selector } from 'testcafe';
test('Select option', async t => {
const dropdown = Selector('.section')
.find('.Select.is-clearable.is-searchable.Select--multi')
.find('.Select-control')
.find('.Select-placeholder')
.withText('Select...');
await t.click(dropdown);
await t.typeText(dropdown, 'abc'); // unable to pass text 'abc'
await t.wait(3000);
});
使用类似组件的示例站点 http://jedwatson.github.io/react-select/
const dropdown = Selector('.section')
.find('.Select.is-clearable.is-searchable.Select--multi')
.find('.Select-control')
.find('.Select-placeholder')
.withText('Select...');
const inputField = dropdown
.sibling('.Select-input')
.find('input');
await t
// wait until element is visible on the screen
.expect(dropdown.with({visibilityCheck: true}).exists).ok({timeout: 5000})
// access the element via the mouse (will fire the mouse event onMouseEnter)
.hover(dropdown)
.click(dropdown)
.typeText(inputField, 'abc');