Skip to content
Merged

Develop #2193

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions source/api/commands/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ Option | Default | Description
cy.get('.second').next()
```

### Testing a datalist
```html
<input list="fruit" />
<datalist id="fruit">
<option>Apple</option>
<option>Banana</option>
<option>Cantaloupe</option>
</datalist>
```

```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`
Expand Down
15 changes: 15 additions & 0 deletions source/api/commands/type.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<input list="fruit" />
<datalist id="fruit">
<option>Apple</option>
<option>Banana</option>
<option>Cantaloupe</option>
</datalist>
```

```javascript
cy.get('input').type('Apple')
```

## Tabindex

### Type into a non-input or non-textarea element with `tabindex`
Expand Down
59 changes: 59 additions & 0 deletions source/api/cypress-api/dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down Expand Up @@ -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.**
Expand All @@ -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.**
Expand All @@ -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.**
Expand All @@ -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
})
```
1 change: 1 addition & 0 deletions source/examples/examples/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions source/faq/questions/using-cypress-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}.
2 changes: 1 addition & 1 deletion source/guides/references/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}.
Please see our official {% url "Dashboard Product Board" https://portal.productboard.com/cypress-io/1-cypress-dashboard %}.