- Cypress - Discussion
- Cypress - Useful Resources
- Cypress - Quick Guide
- Cypress - GitHub
- Cypress - Plugins
- Cypress - Reports
- Cypress - Configuration of JSON File
- Cypress - Hooks
- Cypress - Environment Variables
- Cypress - Fixtures
- Cypress - Custom Commands
- Cypress - Debugging
- Cypress - Screenshots and Videos
- Cypress - Dashboards
- Cypress - Prompt Pop-up Window
- Cypress - Data Driven Testing
- Cypress - File Upload
- Cypress - Get and Post
- Cypress - Cookies
- Cypress - Mouse Actions
- Cypress - Web Tables
- Cypress - Frames
- Cypress - Hidden Elements
- Cypress - Child Windows
- Cypress - Alerts
- Cypress - Dropdown
- Cypress - Tabs
- Cypress - Checkbox
- Cypress - jQuery
- Cypress - Working with XHR
- Cypress - Asynchronous Behavior
- Cypress - Text Verification
- Cypress - Assertions
- Cypress - Locators
- Cypress - Aliases
- Cypress - Variables
- Cypress - Basic Commands
- Cypress - Supported Browsers
- Cypress - Build First Test
- Cypress - Test Runner
- Cypress - Architecture and Environment Setup
- Cypress - Introduction
- Cypress - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Cypress - Hooks
台风Hooks用于在每次/每次检测之前进行某些操作。 其中一些共同点如下:
before − It is executed, once the prior execution of any tests within a describe block is carried out.
after − It is executed, once the post execution of all the tests within a describe block is carried out.
beforeEach − It is executed prior to the execution of an inspanidual, it blocks within a describe block.
afterEach − It is executed post execution of the inspanidual, it blocks within a describe block.
Implementation
The implementation of directs for the Cypress Hooks is below -
describe( Tutorialspoint , function() { before(function() { // executes once prior all tests in it block cy.log("Before hook") }) after(function() { // executes once post all tests in it block cy.log("After hook") }) beforeEach(function() { // executes prior each test within it block cy.log("BeforeEach hook") }) afterEach(function() { // executes post each test within it block cy.log("AfterEac hook") }) it( First Test , function() { cy.log("First Test") }) it( Second Test , function() { cy.log("Second Test") }) })
产出如下:
产出记录显示,第一个执行步骤是“一切照旧”。
最后一个执行步骤是AFTER ALL。 两人只住过一次。
The step executed under BEFORE EACH ran twice (before each TEST BODY).
此外,根据AFTER EACH执行的两步行动(在每一技术设备之后)。
两个区块均按执行顺序执行。
TAG
除hoo外,Cypress还有tag子——只有和.skip。
虽然只有tag子被利用去执行它被拖到的路障,但情况并非如此。 ski门被利用,排除了被拖到哪块。
Implementation with .only
The implementation of . only tag in Cypress is as follows -
describe( Tutorialspoint , function() //it block with tag .only it.only( First Test , function() { cy.log("First Test") }) //it block with tag .only It.only( Second Test , function() { cy.log("Second Test") }) it( Third Test , function() { cy.log("Third Test") }) })
产出如下:
产出记录显示,只有标的区块(第一次和第二次试验)只有行标。
Implementation with .skip
The implementation of .skip tag in Cypress is as follows -
describe( Tutorialspoint , function() it( First Test , function() { cy.log("First Test") }) it( Second Test , function() { cy.log("Second Test") }) //it block with tag .skip it.skip( Third Test , function() { cy.log("Third Test") }) })
产出如下:
产出记录显示,与ski子的 block块(第三次测试)从执行中跳出。
Advertisements