Вы можете использовать свойство childNodes
DOM и API TestCafe ClientFunction
для достижения требуемого поведения. Следующий тестовый пример демонстрирует этот подход:
import { Selector, ClientFunction } from 'testcafe';
fixture `My fixture`
.page `https://b22yw.csb.app/`;
test('Check navlink text', async t => {
const navLink = Selector('.nav-link');
const getNavLinkText = ClientFunction(() => navLink().childNodes[0].textContent.trim(), {
dependencies: { navLink }
});
await t.expect(getNavLinkText()).eql('Gaps in Care');
});