Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load external test data using Cypress.
Cypress
cy.fixture('[1]').then((data) => { cy.log(data.username); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-JSON file like .txt or .yaml with cy.fixture causes errors.
Forgetting to include the file extension in the fixture name.
✗ Incorrect
Using cy.fixture with a JSON file like 'testData.json' loads external test data correctly in Cypress.
2fill in blank
mediumComplete the code to use external test data for filling a login form.
Cypress
cy.fixture('users.json').then((users) => { cy.get('#username').type(users.[1]); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'password' or 'email' when the input expects username.
Using keys that do not exist in the fixture data.
✗ Incorrect
The 'username' field from the external data is used to fill the username input.
3fill in blank
hardFix the error in the code to correctly assert the loaded test data.
Cypress
cy.fixture('data.json').then((data) => { expect(data.[1]).to.equal('admin'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using keys like 'user' or 'role' that do not match the expected value.
Typos in the key name causing undefined values.
✗ Incorrect
The 'username' key holds the value 'admin' in the test data, so the assertion passes.
4fill in blank
hardFill both blanks to create a reusable test that uses external data for login and asserts the welcome message.
Cypress
cy.fixture('[1]').then((user) => { cy.get('#username').type(user.username); cy.get('#password').type(user.[2]); cy.get('#loginBtn').click(); cy.contains('Welcome').should('be.visible'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect fixture file names like 'userData.json' when the file is 'loginData.json'.
Using 'email' instead of 'password' for the password input.
✗ Incorrect
The fixture file 'loginData.json' contains the user data, and 'password' is the correct key for the password field.
5fill in blank
hardFill all three blanks to load external test data, perform login, and verify the user role on the dashboard.
Cypress
cy.fixture('[1]').then((user) => { cy.get('#username').type(user.[2]); cy.get('#password').type(user.password); cy.get('#loginBtn').click(); cy.get('.role').should('contain.text', user.[3]); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong fixture file names like 'login.json'.
Using incorrect keys like 'email' or 'id' instead of 'username' or 'role'.
✗ Incorrect
The fixture file 'users.json' contains user data; 'username' is used for login input, and 'role' is checked on the dashboard.