使用 Testcafe 选择器:withText then sibling

Using Testcafe Selectors: withText then sibling

我正在尝试创建 select 或使用 withText 过滤器并希望 select 兄弟元素。

给定:const Create_asset = S('span').withText('Create Asset')

Create_asset() returns 一个 ReExecutablePromisenextSibling() 方法。 await Create_asset() returns 一个 DOM-like(?) 对象,但是没有 nextSibling() 方法,所以我似乎不能做 await Create_asset().withText('text').nextSibling()

如何在使用 withText() 过滤器时 select 一个兄弟姐妹?

也感谢任何调试提示!

下面的代码returns一个DOM Node Snapshot.

const mySelector = Selector('span').withText('text');
const snapshot   = await mySelector();

在您的测试场景中,您可以这样做:

await t

    .expect(mySelector.withText('some text').nextSibling().getAttribute('id')).eql('id1');

注:TestCafe allows you to debug server-side test code and test behavior on the client