|
| 1 | +describe('Command Options and UI Display Tests', () => { |
| 2 | + it('commands that do not appear in command log', () => { |
| 3 | + cy.visit('cypress/fixtures/commandsActions.html') |
| 4 | + |
| 5 | + cy.wrap({ foo: { bar: 'baz' } }) |
| 6 | + .then((obj) => obj) |
| 7 | + .should('have.property', 'foo') |
| 8 | + .and('have.property', 'bar') |
| 9 | + |
| 10 | + cy.wrap({ foo: { bar: 'baz' } }) |
| 11 | + .as('myObject') |
| 12 | + |
| 13 | + cy.get('@myObject').then((obj) => { |
| 14 | + cy.log(obj) |
| 15 | + }) |
| 16 | + |
| 17 | + cy.get('div').each(($div) => { }).end() |
| 18 | + |
| 19 | + cy.fixture('uiStates') |
| 20 | + |
| 21 | + cy.intercept('GET', 'comments/*').as('getComment') |
| 22 | + |
| 23 | + cy.wrap(['foo', 'bar']).spread(() => {}) |
| 24 | + |
| 25 | + const obj = { |
| 26 | + foo () { }, |
| 27 | + bar () { }, |
| 28 | + } |
| 29 | + |
| 30 | + cy.spy(obj, 'foo') |
| 31 | + cy.stub(obj, 'bar') |
| 32 | + }) |
| 33 | + |
| 34 | + it('form interaction command options', () => { |
| 35 | + cy.visit('cypress/fixtures/uiStates.html') |
| 36 | + |
| 37 | + cy.get('#a').focus().blur({ force: false }) |
| 38 | + cy.get('#checkbox').check({ force: false }) |
| 39 | + cy.get('form').children({ timeout: 2000 }) |
| 40 | + cy.get('#a').clear({ force: false }) |
| 41 | + cy.clearCookie('authId', { timeout: 2001 }) |
| 42 | + cy.clearCookies({ timeout: 2002 }) |
| 43 | + |
| 44 | + cy.contains('button').click({ force: false }) |
| 45 | + cy.contains('button').click(1, 2, { force: false }) |
| 46 | + cy.contains('button').click('bottom', { force: false }) |
| 47 | + }) |
| 48 | + |
| 49 | + it('DOM traversal command options', () => { |
| 50 | + cy.visit('cypress/fixtures/uiStates.html') |
| 51 | + |
| 52 | + cy.get('#a').closest('form', { timeout: 2003 }) |
| 53 | + cy.contains('.test', 'Hello', { timeout: 2004 }) |
| 54 | + cy.get('button').dblclick({ force: false }) |
| 55 | + |
| 56 | + cy.document({ timeout: 2005 }) |
| 57 | + |
| 58 | + cy.get('input').eq(0, { timeout: 2006 }) |
| 59 | + cy.exec('ls', { env: { 'a': true } }) |
| 60 | + cy.get('input').filter('#a', { timeout: 2007 }) |
| 61 | + cy.get('form').find('#a', { timeout: 2008 }) |
| 62 | + cy.get('input').first({ timeout: 2009 }) |
| 63 | + }) |
| 64 | + |
| 65 | + it('element state and navigation command options', () => { |
| 66 | + cy.visit('cypress/fixtures/uiStates.html') |
| 67 | + |
| 68 | + cy.get('#a').focus({ timeout: 2010 }) |
| 69 | + cy.get('#a').focus() |
| 70 | + cy.focused({ timeout: 2011 }) |
| 71 | + cy.get('#a', { withinSubject: document.forms[0] }) |
| 72 | + cy.getCookie('auth_key', { timeout: 2012 }) |
| 73 | + cy.getCookies({ timeout: 2013 }) |
| 74 | + cy.go('forward', { timeout: 2014 }) |
| 75 | + cy.hash({ timeout: 2015 }) |
| 76 | + cy.get('input').last({ timeout: 2016 }) |
| 77 | + cy.location('port', { timeout: 2017 }) |
| 78 | + cy.get('#a').next('input', { timeout: 2018 }) |
| 79 | + cy.get('#a').nextAll('input', { timeout: 2019 }) |
| 80 | + }) |
| 81 | + |
| 82 | + it('element traversal and file operations command options', () => { |
| 83 | + cy.visit('cypress/fixtures/uiStates.html') |
| 84 | + |
| 85 | + cy.get('#a').nextUntil('#b', { timeout: 2020 }) |
| 86 | + cy.get('input').not('#a', { timeout: 2021 }) |
| 87 | + cy.get('#a').parent('form', { timeout: 2022 }) |
| 88 | + cy.get('#a').parents('form', { timeout: 2023 }) |
| 89 | + cy.get('#a').parentsUntil('body', { timeout: 2024 }) |
| 90 | + cy.get('#b').prev('input', { timeout: 2025 }) |
| 91 | + cy.get('#b').prevAll('input', { timeout: 2026 }) |
| 92 | + cy.get('#b').prevUntil('#a', { timeout: 2027 }) |
| 93 | + cy.readFile('./cypress/fixtures/uiStates.json', { timeout: 2028 }) |
| 94 | + cy.reload(true, { timeout: 2028 }) |
| 95 | + cy.get('button').rightclick({ timeout: 2028 }) |
| 96 | + cy.root({ timeout: 2028 }) |
| 97 | + }) |
| 98 | + |
| 99 | + it('scrolling and form interaction command options', () => { |
| 100 | + cy.visit('cypress/fixtures/uiStates.html') |
| 101 | + |
| 102 | + cy.screenshot({ capture: 'viewport' }) |
| 103 | + cy.get('form').scrollIntoView({ |
| 104 | + offset: { top: 20, left: 30, right: 20, bottom: 40 }, |
| 105 | + log: true, |
| 106 | + timeout: 3000, |
| 107 | + duration: 0, |
| 108 | + }) |
| 109 | + |
| 110 | + cy.scrollTo(0, 500, { duration: 100 }) |
| 111 | + cy.get('#fruits').select('apples', { force: false }) |
| 112 | + cy.setCookie('auth_key', '123key', { httpOnly: true }) |
| 113 | + cy.get('#a').siblings('input', { timeout: 2029 }) |
| 114 | + cy.get('form').submit({ timeout: 2030 }) |
| 115 | + cy.title({ timeout: 2032 }) |
| 116 | + }) |
| 117 | + |
| 118 | + it('user interaction and window command options', () => { |
| 119 | + cy.visit('cypress/fixtures/uiStates.html') |
| 120 | + |
| 121 | + cy.get('#a').trigger('mouseenter', 'top', { cancelable: true }) |
| 122 | + cy.get('#a').type('hi?', { |
| 123 | + delay: 10, |
| 124 | + force: true, |
| 125 | + }) |
| 126 | + |
| 127 | + cy.get('#checkbox').uncheck('good', { force: false }) |
| 128 | + cy.url({ timeout: 2033 }) |
| 129 | + cy.visit('cypress/fixtures/uiStates.html', { |
| 130 | + timeout: 20000, |
| 131 | + }) |
| 132 | + |
| 133 | + cy.wait(100, { requestTimeout: 2000 }) |
| 134 | + cy.window({ timeout: 2034 }) |
| 135 | + cy.wrap({ name: 'John Doe' }, { timeout: 2035 }) |
| 136 | + cy.writeFile('./cypress/_test-output/test.txt', 'test', { timeout: 2036 }) |
| 137 | + }) |
| 138 | + |
| 139 | + it('verify element visibility state', () => { |
| 140 | + cy.visit('cypress/fixtures/commandsActions.html') |
| 141 | + |
| 142 | + cy.get('#scroll-horizontal button') |
| 143 | + .should('not.be.visible') |
| 144 | + }) |
| 145 | +}) |
0 commit comments