This is an example of how to use a viewport to emulate different device’s screens:
describe('Device Tests', () => {
it('1080p', () => {
cy.viewport(1980, 1080);
cy.visit('https://books.toscrape.com/')
cy.wait(3000);
});
it('iPhone X', () => {
cy.viewport('iphone-x');
cy.visit('https://books.toscrape.com/')
cy.wait(3000);
});
})
As we can see together, I use cy.viewport to declare the size of the screen. In addition to using the size of the resolution, the viewport can also be defined using the type of device.
Save the above test files as and run the test as per the steps mentioned in the article “Cypress Test: Create your first End to End Testing”.
Now, you can see, Cypress will open the site using two different devices screen.
The figure below is a screen for desktop
The figure below is a screen for iPhone X
Conclusion
Using the viewport, we can simulate testing using various screen sizes
Follow me on
Facebook: https://www.facebook.com/mydoqa/
Instagram: https://www.instagram.com/mydoqa/
Twitter: https://twitter.com/MydoQa
This article is a part of the Cypress Test series. To read another story, please follow the links below:
Cypress Test Series:
API Test Series:
- API Test: Create your first API Testing in POSTMAN
- API Test: How to assert array in response body using Postman
- API Test: How to loop request in Postman
- API Test: How to test HTTP methods using Postman
- API Test: How to assert JWT Token content using Postman
Software Testing Series:
- What is Software Testing?
- 7 Principles Of Software Testing
- 6 Major Steps of Software Testing Life Cycle (STLC)
- 10 Must-Have Skills for Software Testers
- Soft skill for tester: Keys for effective communication
- Software Testing Approaches
- QA Techniques: Black Box Testing
- QA Techniques: White Box Testing
0 comments:
Post a Comment