Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the viewport to a mobile screen size.
Cypress
cy.[1]('iphone-6')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
cy.visit() instead of cy.viewport().Trying to set viewport size with
cy.get().✗ Incorrect
The cy.viewport() command sets the screen size for testing different devices.
2fill in blank
mediumComplete the code to set the viewport to a custom width and height.
Cypress
cy.viewport({ width: [1], height: 800 }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting width value in quotes, which causes errors.
Using property names instead of values.
✗ Incorrect
The width value must be a number without quotes to set the viewport size correctly.
3fill in blank
hardFix the error in the code to set the viewport to tablet size.
Cypress
cy.viewport({ width: 768, [1]: 1024 }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
width twice instead of height.Using invalid property names like
size or screen.✗ Incorrect
The correct property for height is height, not width or others.
4fill in blank
hardFill both blanks to set the viewport to a landscape iPad size.
Cypress
cy.viewport({ width: [1], height: [2] }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height values.
Using incorrect pixel values.
✗ Incorrect
Landscape iPad size is width 1024 and height 768 pixels.
5fill in blank
hardFill all three blanks to set the viewport to a custom size and test a page.
Cypress
cy.viewport({ width: [1], height: [2] })
cy.[3]('https://example.com') Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
click instead of visit to open the page.Putting width or height in quotes.
Swapping width and height values.
✗ Incorrect
Set viewport width to 1280, height to 720, then visit the page with cy.visit().