-
Notifications
You must be signed in to change notification settings - Fork 2
/
at.cy.js
47 lines (41 loc) · 1.18 KB
/
at.cy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/// <reference types="cypress" />
// @ts-check
import '../../commands'
it('cy.eq yields the jQuery object', () => {
cy.visit('cypress/index.html')
cy.get('.matching')
.eq(1)
.should('satisfy', Cypress.dom.isJquery)
.invoke('text')
.should('equal', 'third')
cy.get('.matching')
.eq(2)
.should('satisfy', Cypress.dom.isJquery)
.and('have.length.above', 0)
.invoke('text')
.should('equal', 'fourth')
})
it('cy.at yields the DOM element', () => {
cy.visit('cypress/index.html')
cy.get('.matching')
.at(1)
.should('satisfy', Cypress.dom.isElement)
.its('innerText')
.should('equal', 'third')
cy.get('.matching')
.at(2)
.should('satisfy', Cypress.dom.isElement)
.its('innerText')
.should('equal', 'fourth')
})
it('cy.at yields the last DOM element for index -1', () => {
cy.visit('cypress/index.html')
cy.get('#items li').at(-1).its('innerText').should('equal', 'fifth')
})
it('cy.at yields an element in the array', () => {
cy.wrap([1, 2, 3]).at(2).should('equal', 3)
})
it('cy.at the last element of the array for -1', () => {
cy.wrap([1, 2, 3]).at(-1).should('equal', 3)
cy.wrap([1, 2, 3]).at(-2).should('equal', 2)
})