refined-breakfast-53252
05/05/2022, 11:50 PMadorable-smartphone-87280
05/06/2022, 3:43 AMloud-vase-48777
05/06/2022, 7:06 AMmammoth-fall-22117
05/06/2022, 8:53 AMcy.get('[data-testid="button-id"]')
.then('[data-testid="button-id"]') => {
if (cy.get('[data-testid="button-id"]').should('be.enabled').false)
{
cy.get('[data-testid="button-switch-0"]').click()
}
else {}
}
I get this error and the code won't 'compile': "Expecting newline or semicolon".
Any ideas what did I do wrong?echoing-painting-40909
05/06/2022, 9:32 AM.then('[data-testid="button-id"]') =>
.then
expects a callback :
.then(() => {})
// wrong syntax
.then() => {}
The arrow is outside of then in your example
Besides that, passing a string '[data-testid="button-id"]'
won't work.mammoth-fall-22117
05/06/2022, 9:50 AMcy.get('[data-testid="button-id"]').then(($btn) => {
if (($btn).is('disabled')) {
cy.get('[data-testid="button-id"]').click()
}
else {}
})
However, I have a problem with this IF condition now, because whatever I write there it never passes... (So if the button is disabled it never clicks it).echoing-painting-40909
05/06/2022, 9:53 AMmammoth-fall-22117
05/06/2022, 9:55 AMbrash-autumn-47936
05/06/2022, 10:03 AMechoing-painting-40909
05/06/2022, 10:33 AMdisabled
to :disabled
:
ts
// from
if (($btn).is('disabled')) {
// to
if (($btn).is(':disabled')) {
mammoth-fall-22117
05/06/2022, 10:38 AMgray-kilobyte-89541
05/06/2022, 10:38 AMmammoth-fall-22117
05/06/2022, 10:39 AMgray-kilobyte-89541
05/06/2022, 10:39 AMrefined-breakfast-53252
05/06/2022, 11:44 AMrefined-breakfast-53252
05/06/2022, 12:27 PMadorable-smartphone-87280
05/06/2022, 3:23 PMadorable-smartphone-87280
05/06/2022, 3:24 PMsparse-cpu-70188
05/06/2022, 4:40 PMrefined-breakfast-53252
05/06/2022, 8:42 PMadorable-smartphone-87280
05/06/2022, 9:52 PMmammoth-fall-22117
05/07/2022, 6:06 AMcy.get('[id="some-input"]')
.clear()
.type(number)
cy.get('[data-testid="update-button"]')
.should('be.enabled')
.click()
cy.contains(number) >> Will fail because number is not 1234 but 1'234
magnificent-finland-58048
05/07/2022, 10:22 AMmammoth-fall-22117
05/07/2022, 10:30 AMgray-kilobyte-89541
05/07/2022, 12:40 PMmammoth-fall-22117
05/07/2022, 12:40 PMmammoth-fall-22117
05/07/2022, 12:41 PMgray-kilobyte-89541
05/07/2022, 1:15 PM'
every 3 characters?mammoth-fall-22117
05/07/2022, 1:19 PMgray-kilobyte-89541
05/07/2022, 9:50 PM