YouTube: To watch in YouTube click here
1. How can you run a single spec file(test case) from the command line ?
You can use below code:
npm cypress run – spce = “spce file name”
2. How can you get the first and the last element from the selected list of elements ?
We can use first() and last() commands:
For example:
Suppose below locator returns a list of elements,ie, more than one elements.
cy.get(‘locator’)
To get the first and the last elements use below codes:
cy.get(‘locator’).first()
cy.get(‘locator’).last()
3. How you click the hidden element ?
You can use force:true like below:
cy.get(‘locator’).check({force:true})
cy.get(‘locator’).click({force:true})
4. How you click hidden link(DOM) ?
You can use shadow() function like below:
cy.get(‘locator’).shadow().find(‘locator’).click()
5. How can you press keyboard keys ?
You can use ‘type’ command like below:
cy.get(‘locator’).type('{del}'));
cy.get(‘locator’).type('{enter}'));
cy.get(‘locator’).type('{backspace}'));
cy.get(‘locator’).type('{esc}'));
cy.get(‘locator’).type(‘{shift}{alt}’)
6. How to run in a headless mode ?
You can use ‘headless’ keyword like below:
npx cypress run --headless -b chrome --spec "path\specfile.js"
npx cypress run --headless -b firefox --spec "path\specfile.js"
7. How to run in a headed mode ?
You can use ‘headed’ keyword like below:
npx cypress run --headed -b chrome --spec "path\specfile.js"
npx cypress run --headed -b firefox --spec "path\specfile.js"
8. How you get log in cypress?
Using cy.log() you can get log in the console.
cy.log('test execution started')
cy.log('login successful')
cy.log('logout successful')
cy.log('test execution ended')
9. How you capture screenshot in cypress ?
Cypress by default takes screenshot of the failed test tests, it takes screenshot of each step after it completes the step. But if you want to take screenshot of any particular step then you can use below command:
cy.screenshot()
10. What are the disadvantages/limitations of cypress ?
Supports web based applications only.
Supports only java script and type script.
Does not support multiple tabs
Does not support mobile apps.
Only CSS Selector can be used as a locator. Xpath can be used with the plug in cypress-xpath.
Supports some browsers only such as Chrome, Fireforx, EDGE, Chromium and Electorn
11. What are the differences between Cypress and Selenium ?
Scripts/Programming languages:
Selenium: Java, Python, C#, Java Script, Perl, PHP, Ruby
Cypress: Java Script and Type Script
Browsers:
Selenium: chrome, firefox, safari, IE, Opera, Edge
Cypress: chrome, firefox, Edge, Chromium, Electron
Locators:
Selenium: name, class, id, link, partial link, xpath, CSS selector
Cypress: CSS Selector and xpath(with plug in)
Mobile testing:
Selenium: supports mobile testing
Cypress: Does not support mobile testing, mobile apps. Workaround is ViewPort()
Browser Tabs:
Selenium: Supports Tabs
Cypress : Does not support Tabs
Speed:
Selenium : Test execution happens outside the browser so it is slow
Cypress: Test execution happens inside the browser and it is fast
Screenshot:
Selenium: Does not take screenshot by default
Cypress: Takes screenshot bydefault of each steps and failed tests.
Video:
Selenium: Video testing is not supported
Cypress: Supports Video testing as well as creates video of the test execution
No comments:
Post a Comment