我有一个React Hook表单包含自动完成的Material UI控件。
我希望运行一个cypress测试用例来填写表单并提交。如何使用cypress选择这个组件中的第一个选项。
目前我只是尝试了以下方法。
<Controller
as={
<Autocomplete
data-cy="profileCountry"
options={countries}
getOptionLabel={option => option.name}
renderInput={params => (
<TextField
{...params}
label="* Country"
placeholder="Select a Country"
InputLabelProps={{
shrink: true
}}
variant="outlined"
/>
)}
/>
}
rules={{ required: true }}
onChange={([, data]) => data}
defaultValue={{ id: 0, name: "" }}
getOptionSelected={(option, value) => option.id === value.id}
name="country"
id="country"
control={control}
/>
我希望运行一个cypress测试用例来填写表单并提交。如何使用cypress选择这个组件中的第一个选项。
目前我只是尝试了以下方法。
cy.get("[data-cy=profileCountry]").select("Germany");