I'm using Cypress 3.3.1
As an example that others can test, consider the following code:
cy.visit(') cy.get('input[type=text]').each((el, index) => { if (index === 0) { cy.wrap(el).type('some text') } }) cy.contains('Google Search').click() For some reason cy.contains('Google Search').click() is not able to find the element.
If I call cy.wrap('body') before I call .contains('Google Search') that now works. Suggesting that if you wrap an element, it changes some global context, and then has to be reset. No mention of this in the docs as far as I can see.
This code works:
cy.visit(') cy.get('input[type=text]').each((el, index) => { if (index === 0) { cy.wrap(el).type('some text') } }) cy.wrap('body') cy.contains('Google Search').click() Are you supposed to 'reset' the context after using wrap() or am I misunderstanding how it should be used?
Related questions 3 cy.wrap() - difference between passing a string or object 1 Cypress.io can't find the specs when wrapping with nodejs 4 How to extract and use a string value returned from cy.wrap() Related questions 3 cy.wrap() - difference between passing a string or object 1 Cypress.io can't find the specs when wrapping with nodejs 4 How to extract and use a string value returned from cy.wrap() 24 Is being covered by another element Cypress 1 Cypress: Adding tests dynamically within a wrap 1 Use a wraped variable in the type() function. Cypress 0 Return value from nested wrap 1 Cypress cy.request .then chaining returning undefined 2 cy.wrap().its()... doesn't work when the value in .its() contains a period 0 Cypress Error "Attempted to wrap warn which is already wrapped" Load 7 more related questions Show fewer related questions
Reset to default