Skip to content

Instantly share code, notes, and snippets.

@brian-mann
Last active March 20, 2017 18:25
Show Gist options
  • Save brian-mann/6884d1cca0a1f5f2b9643c888dec0473 to your computer and use it in GitHub Desktop.
Save brian-mann/6884d1cca0a1f5f2b9643c888dec0473 to your computer and use it in GitHub Desktop.
custom command works
Cypress.addParentCommand('getCheckbox', function (labelText) {
return cy.chain().get('label').contains(labelText).find('input[type="checkbox"]')
})
Cypress.addParentCommand("requestUrl", function(url) {
// url = baseUrl + url;
return cy.chain().request(url);
});
it('works', function(){
cy.visit('/index.html')
cy.getCheckbox('foo').should('be.checked')
})
it('works on request', function(){
cy
.requestUrl('http://www.example.com').then(function(response){
expect(response).to.be.ok
})
})
<!DOCTYPE html>
<html>
<body>
<label>
foo
<input type='checkbox' checked />
</label>
</body>
</html>
@brian-mann
Copy link
Author

screen shot 2017-03-20 at 2 18 04 pm

@brian-mann
Copy link
Author

screen shot 2017-03-20 at 2 25 10 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment