diff --git a/source/api/commands/next.md b/source/api/commands/next.md index e80e07bb89..33c8398a1c 100644 --- a/source/api/commands/next.md +++ b/source/api/commands/next.md @@ -70,6 +70,23 @@ Option | Default | Description cy.get('.second').next() ``` +### Testing a datalist +```html + + + + + + +``` + +```javascript +cy.get('#fruit option') + .first().should('have.text', 'Apple') + .next().should('have.text', 'Banana') + .next().should('have.text', 'Cantaloupe') +``` + ## Selector ### Find the very next sibling of each li. Keep only the ones with a class `selected` diff --git a/source/api/commands/type.md b/source/api/commands/type.md index 2b444db3ed..f6bd41373a 100644 --- a/source/api/commands/type.md +++ b/source/api/commands/type.md @@ -106,6 +106,21 @@ Each keypress is delayed 10ms by default in order to simulate how a very fast us cy.get('[contenteditable]').type('some text!') ``` +### 'Selecting' an option from datalist +For 'selecting' an option, just type it into the input. +```html + + + + + + +``` + +```javascript +cy.get('input').type('Apple') +``` + ## Tabindex ### Type into a non-input or non-textarea element with `tabindex` diff --git a/source/api/cypress-api/dom.md b/source/api/cypress-api/dom.md index b3f312875e..f3a1ba8281 100644 --- a/source/api/cypress-api/dom.md +++ b/source/api/cypress-api/dom.md @@ -18,6 +18,26 @@ Cypress.dom.isHidden(element) # Examples +## Is attached + +**Returns a boolean indicating whether an element is attached to the DOM.** + +```javascript +cy.get('button').then(($el) => { + Cypress.dom.isAttached($el) // true +}) +``` + +## Is descendent + +**Returns a boolean indicating whether an element is a descendent of another element.** + +```javascript +cy.get('div').then(($el) => { + Cypress.dom.isDescendent($el.parent(), $el) // true +}) +``` + ## Is detached **Returns a boolean indicating whether an element is detached from the DOM.** @@ -48,6 +68,16 @@ cy.get('body').then(($el) => { }) ``` +## Is element + +**Returns a boolean indicating whether an object is a DOM element.** + +```javascript +cy.get('p').then(($el) => { + Cypress.dom.isElement($el) // true +}) +``` + ## Is focusable **Returns a boolean indicating whether an element can receive focus.** @@ -60,6 +90,16 @@ cy.get('input').then(($el) => { }) ``` +## Is focused + +**Returns a boolean indicating whether an element currently has focus.** + +```javascript +cy.get('button').then(($el) => { + Cypress.dom.isFocused($el) +}) +``` + ## Is hidden **Returns a boolean indicating whether an element is hidden.** @@ -72,6 +112,16 @@ cy.get('p').then(($el) => { }) ``` +## Is jQuery + +**Returns a boolean indicating whether an object is a jQuery object.** + +```javascript +cy.get('input').then(($el) => { + Cypress.dom.isJquery($el) +}) +``` + ## Is scrollable **Returns a boolean indicating whether an element is scrollable.** @@ -94,3 +144,12 @@ cy.get('img').then(($el) => { }) ``` +## Is window + +**Returns a boolean indicating whether an object is a window object.** + +```javascript +cy.get(window).then(($el) => { + Cypress.dom.isWindow($el) // true +}) +``` diff --git a/source/examples/examples/recipes.md b/source/examples/examples/recipes.md index ea360bc3a3..fde0b812bf 100644 --- a/source/examples/examples/recipes.md +++ b/source/examples/examples/recipes.md @@ -68,6 +68,7 @@ Recipe | Description {% url 'Stubbing `window.fetch`' https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/stubbing-spying__window-fetch %} | Use `cy.stub()` to control fetch requests {% url 'Stub methods called on `window`' https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/stubbing-spying__window %} | Use `cy.stub()` for methods called on `window` {% url 'Stubbing Google Analytics' https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/stubbing-spying__google-analytics %} | Use `cy.stub()` to test Google Analytics calls +{% url 'Stub methods called on `console`' https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/stubbing-spying__console %} | Use `cy.stub()` to test and control methods called on `console` ## Unit Testing Recipe | Description diff --git a/source/faq/questions/using-cypress-faq.md b/source/faq/questions/using-cypress-faq.md index 0f204c1d71..a38bed2956 100644 --- a/source/faq/questions/using-cypress-faq.md +++ b/source/faq/questions/using-cypress-faq.md @@ -587,3 +587,19 @@ Usually your end-to-end tests interact with the application through public brows - see {% url "Testing Redux Store" https://www.cypress.io/blog/2018/11/14/testing-redux-store/ %} blog post and {% url "Redux Testing" recipes#Blogs %} recipe. - see {% url "Testing Vue web applications with Vuex data store & REST back end" https://www.cypress.io/blog/2017/11/28/testing-vue-web-application-with-vuex-data-store-and-rest-backend/ %} blog post and {% url 'Vue + Vuex + REST Testing' recipes#Blogs %} recipe. + +## {% fa fa-angle-right %} How do I spy on console.log? + +To spy on ```console.log``` you should use {% url "`cy.stub()`" stub %}. + +```javascript +cy.visit('/', { + onBeforeLoad(win) { + cy.stub(win.console, 'log').as('consoleLog') + } +}) +//... +cy.get('@consoleLog').should('be.calledWith', 'Hello World!') +``` + +Also, check out our {% url 'Stubbing `console` Receipe' recipes#Stubbing-and-spying %}. diff --git a/source/guides/references/roadmap.md b/source/guides/references/roadmap.md index ab9356033a..703eca5528 100644 --- a/source/guides/references/roadmap.md +++ b/source/guides/references/roadmap.md @@ -22,4 +22,4 @@ Status | Feature | Issue | ## Dashboard Service -Please see our official % url "Dashboard Product Board" https://portal.productboard.com/cypress-io/1-cypress-dashboard %}. \ No newline at end of file +Please see our official {% url "Dashboard Product Board" https://portal.productboard.com/cypress-io/1-cypress-dashboard %}. \ No newline at end of file