http://www.technicalpage.net/search/label/SQL

Cypress Interview Questions and Answers Part 3

YouTube: To watch in YouTube , click here

 

1.    What are the Cypress features ?
Cypress has automatic wait
Cypress takes screenshot of each steps and records video of the test execution, Cypress has built-in feature for the screenshots and the videos.
Cypress controls network traffic
Cypress runs inside the browser and is fast
Cypress provides viewport for testing with different page sizes
Cypress runs in multiple browsers: Chrome, Firefox, Edge, Chromium, Electron
Cypress has built-in assertions.

2.     How can we skip test cases in Cypress ?
We can skip test cases using ‘skip’ and ‘only’
When you skip at the ‘describe’, the whole test cases inside the ‘describe’ block will be skipped.

3.    How can we navigate forward or back in the browser in Cypress ?

            To navigate forward, the command is:

            cy.go(‘forward’)

            Or

            cy.go(1)

 

            To navigate back, the command is:

            cy.go(‘back’)

            Or

            cy.go(-1)

4.    How you get the DOM Element(locator) containing the text ?

            we use cy.contains like below:

            cy.contains(‘search’) à this will return the first element on the page which has the string “search”.

            You can use partial string also, such as

            cy.contains(‘sear’)

            cy.contains(‘arch’)

            Suppose you want to click this element then you can write like this:

            cy.contains(‘arch’).click()

 

5.    What are the Cypress functions to traverse DOM ?
prev() prevAll() prevUntil()
parent() parents() parentUntil()
next() nextAll() nextUntil()
children()
siblings()
filter()
first()
last()
find()
eq() 

6.     Can you use Cucumber BDD in cypress ?
Using “Cypress-Cucumber-Preprocessor” plug in, we can use Cucumber BDD in Cypress.

7.     Reusability in Cypress
You can use two files for the reusability purpose: commands.js and index.js in the Support folder. We put reusable codes in these files. The index.js file runs before each test file.

8.     What are the cypress commands to interact with the DOM elements ?
Some of the most common cypress commands to interact with the DOM elements are:
click()
clear()
type()
dbclick()
rightclick()
check()
uncheck()
select()
selectfile()
trigger()

9.    What are the Mocha and the Chai ?
These are Java Script testing libraries. Mocha provides test runner and the Chai provides the assertion libraries.

10.    How you manage the test data in Cypress?
For this we create  test data files(json files) in Fixture folder and save the test data. We use the test data in the “before hook” in the test case using below code:

Cy.fixture(path of the test data file) 

          


No comments:

Post a Comment