

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between JQuery vs Cypress
Cypress can work on JQuery objects and call its methods. Thus Cypress can act upon both Cypress and non- Cypress commands. Cypress is asynchronous in nature. It is handled by resolving promises for every Cypress command. This whole process is taken care of by Cypress internally and wrapped and hidden from the end user.
However while dealing with JQuery methods, the promise cannot be resolved internally by Cypress and we need to manually resolve them with the help of the then() method in the code.
Let us take the example of text() method which is a non-Cypress command and is based on JQuery.
Example
Code Implementation to handle promise for JQuery.
// test suite describe('Tutorialspoint Test', function () { // test case it('Test Case1', function (){ // test step to launch a URL cy.visit("https://www.tutorialspoint.com/index.htm"); // enter test in the edit box // assertion to validate the number of child elements cy.get('#gs_50d > tbody > tr > td'). should('have.length',2); // locate element with get and find method cy.get('#gs_50d > tbody > tr > td'). find('input') //enter test in the edit box .type('Cypress'); //iterate the list items with each command cy.get('.mui-tabs__bar.mui-tabs__bar_1.mui-tabs__bar--justified') .find('li').each(($el, index, $list) => { // extract text with text() method const txt = $el.find('a').text(); if ( txt.includes('Deve')){ $el.click(); } }) //handling promise with then() for non in built Cypress function cy.get('mui-container > h4').then(function(heading){ cy.log(heading.text()); }) }); });
On running the above block of code, Cypress Test runner gives the below output. Please note the log printed with text() method handled with then().
- Related Questions & Answers
- Difference between Testing vs. Checking
- Difference between Backbone.js and Jquery
- Difference between equals() vs equalsIgnoreCase() in Java
- Difference between Unit Test vs. Integration Test
- Difference between Data Mining vs. Machine Learning?
- What is the difference between jQuery add() & jQuery append() methods in jQuery?
- What is the difference between local storage vs cookies?
- Explain the difference between Dark Web Vs Deep Web?
- What is the difference between jQuery and JavaScript?
- What is the difference between jQuery and AngularJS?
- What is the difference between Ajax and jQuery-Ajax methods in jQuery?
- What is the difference between pairs() vs. ipairs() in Lua?
- What is the difference between jQuery(selector) and $(selector)?
- What is difference between innerWidth and outerWidth in jQuery?
- What is the difference between MySQL TINYINT(2) vs TINYINT(1)?