Last active
December 4, 2017 11:47
-
-
Save jennifer-shehane/eaa017496b9b5cfc98e8f4ef31a437fc to your computer and use it in GitHub Desktop.
Selenium versus Cypress.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Kitchen Sink', function(){ | |
it('cy.should - assert that <title> is correct', function(){ | |
cy | |
.visit('https://example.cypress.io/') | |
.title().should('include', 'Kitchen Sink') | |
}) | |
context('Querying', function(){ | |
beforeEach(function(){ | |
cy.visit('https://example.cypress.io/commands/querying') | |
}) | |
it('cy.get() - query DOM elements', function(){ | |
cy | |
// We can get DOM elements by id | |
.get('#query-btn').should('contain', 'Button') | |
// We can get DOM elements by class | |
.get('.query-btn').should('contain', 'Button') | |
// we can CSS selectors just like jQuery | |
.get('#querying .well>button:first').should('contain', 'Button') | |
}) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var selenium = require('selenium-webdriver') | |
var chai = require('chai') | |
var expect = chai.expect | |
chai.use(require('chai-as-promised')) | |
before(function() { | |
this.timeout(10000) | |
this.driver = new selenium.Builder().withCapabilities(selenium.Capabilities.chrome()).build() | |
this.driver.getWindowHandle() | |
}); | |
after(function() { | |
this.driver.quit() | |
}); | |
describe('Kitchen Sink', function() { | |
it('getTitle() - assert that <title> is correct', function() { | |
this.driver.get('https://example.cypress.io/') | |
expect(this.driver.getTitle()).to.eventually.contain('Cypress.io: Kitchen Sink') | |
}); | |
describe('Querying', function() { | |
it('query DOM elements', function() { | |
this.driver.get('https://example.cypress.io/commands/querying') | |
// We can get DOM elements by id | |
var text = this.driver.findElement({id: 'query-btn'}).getText() | |
expect(text).to.eventually.equal('Button') | |
// We can get DOM elements by class | |
text = this.driver.findElement({css: '.query-btn'}).getText() | |
expect(text).to.eventually.equal('Button') | |
// we can CSS selectors just like jQuery | |
text = this.driver.findElement({css: '#querying .well>button:first'}).getText() | |
expect(text).to.eventually.equal('Button') | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment