Q/A-11:
What is the purpose of using the cy.contains() command in Cypress?
A) It is used to check if an element contains specific text.
B) It is used to retrieve an element from the DOM.
C) It is used to interact with form elements.
D) It is used to start the Cypress Test Runner.
A) It is used to check if an element contains specific text.
Q/A-12:
How can you perform assertions in Cypress tests?
A) By using the cy.assert() command.
B) By using the expect() function from an assertion library.
C) By using the cy.validate() command.
D) By using the it() function with a callback.
B) By using the expect() function from an assertion library.
Q/A-13:
What is the purpose of the beforeEach() function in Cypress?
A) It is used to define a custom command.
B) It is used to execute code before each test in a test suite.
C) It is used to set environment variables.
D) It is used to mock API responses.
B) It is used to execute code before each test in a test suite.
Q/A-14:
What is a custom command in Cypress?
A) A user-defined function that can be reused across tests.
B) A command for launching the Cypress Test Runner.
C) A command for generating random test data.
D) A command for starting a local server.
A) A user-defined function that can be reused across tests.
Q/A-15:
How can you skip a test in Cypress?
A) By using the cy.skip() command.
B) By excluding it from the test suite.
C) By using the xit() function.
D) By commenting out the test code.
C) By using the xit() function.
Q/A-16:
What is the purpose of the cy.request() command in Cypress?
A) It is used to retrieve an element from the DOM.
B) It is used to send HTTP requests to a server.
C) It is used to assert the value of an element.
D) It is used to create a custom command.
B) It is used to send HTTP requests to a server.
Q/A-17:
How can you handle authentication in Cypress tests?
A) By using the cy.authenticate() command.
B) By including credentials in the test code.
C) By mocking API responses.
D) By using the cy.request() command with authentication options.
D) By using the cy.request() command with authentication options.
Q/A-18:
What is the purpose of using the cy.route() command in Cypress?
A) It is used to define a custom route in Cypress.
B) It is used to interact with form elements.
C) It is used to mock network requests and responses.
D) It is used to navigate between pages in a web application.
C) It is used to mock network requests and responses.
Q/A-19:
How do you install Cypress plugins in a project?
A) By using the npm install cypress-plugins command.
B) By adding them to the plugins/index.js file in the project.
C) By including them in the cypress.json configuration file.
D) By using the cy.install() command.
B) By adding them to the plugins/index.js file in the project.
Q/A-20:
What is the purpose of using environment variables in Cypress?
A) To store sensitive information like API keys.
B) To define custom assertions in tests.
C) To set up mock data for tests.
D) To specify the browser to be used for testing.