如何编写 Screenplay Task 来测试将键盘状态作为道具传递的 React 组件
How can I write a Screenplay Task to test React components which pass keyboard state as props
我正在尝试测试 ag-grid 组件的行为,它允许我使用键盘或单击来 select 一个单元格,并且网格组件捕获按键并将其传递给我按照 here.
所述编写的编辑器组件
以下工作并模拟用户单击、点击 Enter、键入 5y[= 的情况30=] 并点击 Enter,但我还想在没有中间回车键的情况下验证正确的行为,例如模拟单击,单击,键入 5y 并点击 Enter
actor.attemptsTo(
Click.on(cell),
new Performable() {
@Override
public <T extends Actor> void performAs(final T actor) {
pricerPage.withAction().sendKeys(Keys.ENTER).perform();
}
},
Enter.theValue("5y").into(PricerPage.POPUP_TEXT_EDITOR).thenHit(Keys.ENTER)
)
我似乎无法按预期将 5 按键传递到我的组件,例如以下不会像发送 Enter.
一样触发编辑器组件
actor.attemptsTo(
Click.on(cell),
new Performable() {
@Override
public <T extends Actor> void performAs(final T actor) {
pricerPage.withAction().sendKeys("5").perform();
}
},
Enter.theValue("y").into(PricerPage.POPUP_TEXT_EDITOR).thenHit(Keys.ENTER)
)
是否有更好的方式在没有目标的情况下发送密钥,或者这是正确的方法吗?
我最终调试了我的测试和正在测试的网页 - 我能够观察到键盘事件 key
属性被设置为 'Unidentified' 而不是类似于描述的“5” here
我想这个故事的寓意是,如果您尝试使用旧的锁定版本的浏览器进行自动化,您的里程可能会有所不同...
我正在尝试测试 ag-grid 组件的行为,它允许我使用键盘或单击来 select 一个单元格,并且网格组件捕获按键并将其传递给我按照 here.
所述编写的编辑器组件以下工作并模拟用户单击、点击 Enter、键入 5y[= 的情况30=] 并点击 Enter,但我还想在没有中间回车键的情况下验证正确的行为,例如模拟单击,单击,键入 5y 并点击 Enter
actor.attemptsTo(
Click.on(cell),
new Performable() {
@Override
public <T extends Actor> void performAs(final T actor) {
pricerPage.withAction().sendKeys(Keys.ENTER).perform();
}
},
Enter.theValue("5y").into(PricerPage.POPUP_TEXT_EDITOR).thenHit(Keys.ENTER)
)
我似乎无法按预期将 5 按键传递到我的组件,例如以下不会像发送 Enter.
一样触发编辑器组件actor.attemptsTo(
Click.on(cell),
new Performable() {
@Override
public <T extends Actor> void performAs(final T actor) {
pricerPage.withAction().sendKeys("5").perform();
}
},
Enter.theValue("y").into(PricerPage.POPUP_TEXT_EDITOR).thenHit(Keys.ENTER)
)
是否有更好的方式在没有目标的情况下发送密钥,或者这是正确的方法吗?
我最终调试了我的测试和正在测试的网页 - 我能够观察到键盘事件 key
属性被设置为 'Unidentified' 而不是类似于描述的“5” here
我想这个故事的寓意是,如果您尝试使用旧的锁定版本的浏览器进行自动化,您的里程可能会有所不同...