Q/A-21:
What is a selector in Cypress?
A) It is a function for creating custom assertions.
B) It is a string used to target DOM elements in tests.
C) It is a command for interacting with form elements.
D) It is a way to define custom routes for network requests.
B) It is a string used to target DOM elements in tests.
Q/A-22:
How can you run a specific test file in Cypress?
A) By using the cy.run() command with the file path.
B) By using the cypress run --file option followed by the file path.
C) By using the it.only() function in the test file.
D) By using the cypress open command and selecting the file.
B) By using the cypress run --file option followed by the file path.
Q/A-23:
What is the purpose of using the cy.wait() command in Cypress?
A) It is used to pause test execution for a specified amount of time.
B) It is used to simulate user interactions with the application.
C) It is used to retrieve an element from the DOM.
D) It is used to make assertions in tests.
A) It is used to pause test execution for a specified amount of time.
Q/A-24:
How can you run Cypress tests in a specific browser?
A) By using the cypress run --browser option followed by the browser name.
B) By specifying the browser in the cypress.json configuration file.
C) By using the cy.browser() command in the test code.
D) By setting an environment variable for the desired browser.
A) By using the cypress run --browser option followed by the browser name.
Q/A-25:
What is the purpose of using the cy.contains() command with a regular expression in Cypress?
A) It is used to check if an element contains a specific text pattern.
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 mock network responses.
A) It is used to check if an element contains a specific text pattern.
Q/A-26:
What is the role of a "before" hook in Cypress?
A) It is used to run code before all tests in a test suite.
B) It is used to define custom commands.
C) It is used to mock API responses.
D) It is used to skip a test.
A) It is used to run code before all tests in a test suite.
Q/A-27:
What is the purpose of using the cy.exec() command in Cypress?
A) It is used to execute shell commands outside of the browser.
B) It is used to launch the Cypress Test Runner.
C) It is used to trigger network requests.
D) It is used to validate form data.
A) It is used to execute shell commands outside of the browser.
Q/A-28:
How can you set up a custom reporter for Cypress tests?
A) By using the cypress report command followed by the reporter name.
B) By including the reporter in the plugins/index.js file.
C) By specifying the reporter in the cypress.json configuration file.
D) By using the cy.reporter() command in the test code.
C) By specifying the reporter in the cypress.json configuration file.
Q/A-29:
What is the purpose of using the cy.screenshot() command in Cypress?
A) It is used to take screenshots of the application during test execution.
B) It is used to compare screenshots for visual regression testing.
C) It is used to mock API responses.
D) It is used to record test execution.
A) It is used to take screenshots of the application during test execution.
Q/A-30:
How can you set up continuous integration (CI) for Cypress tests?
A) By using the cypress ci command followed by the CI platform name.
B) By including CI configuration in the cypress.json file.
C) By adding a CI script in the package.json file.
D) By installing a CI plugin from the Cypress marketplace.