I have two questions about the typeText
function.
Selector
would need. I just want to type, like in Cypress, without selecting something first. Is this possible?typeText
method also requires the second parameter (the text). But sometimes, I don't want to put any text into a field (for example testing a login component). Right now, I need to create conditions for these types of tests, because TestCafé throws an error on empty strings. Is there a better way?static async login({ email = '', password = '' }) {
await t
.typeText('#email', email)
.typeText('#password', password)
.click('#submit');
}
Maybe pressKey
would work for you? It requires that the input is separated by spaces but doesn't need a selector. Documentation for pressKey
Example:
await t
.pressKey('u s e r @ t e s t . c o m enter')
.pressKey('p a s s w o r d enter')
I'm making the assumption that enter
or maybe tab
would move to the next field, but I think that could also work for your second point