https://cypress.io logo
Join Discord
Powered by
# help
  • m

    most-thailand-89372

    08/07/2021, 3:46 PM
    Hi everyone, I may have found a "bug", but it may be some configuration issue on my side, so I'm asking here first. I have the following code in a test suite:
    Copy code
    js
    cy.scrollTo('3px', '6px') // cy.scrollTo(3, 6)
    cy.get('.document-position')
      .should('have.text', 'Document scroll position is 3 & 6')
  • m

    most-thailand-89372

    08/07/2021, 3:51 PM
    ... When I run this I get the following error:
    Copy code
    AssertionError
    Timed out retrying after 4000ms: expected '<div.document-position>' to have text 'Document scroll position is 3 & 6', but the text was **'Document scroll position is 1.6666780710220337 & 5.833373069763184'**
    Please note the decimal numbers given instead of the actual 3px and 6px numbers scrolled to. Is this a "feature" or a "bug" or an user error or Murphy's Law?? When I change from "Electron 89" to "FireFox 90" the issue goes away occasionally. Any guidance would be most appreciated.
  • u

    user

    08/09/2021, 10:14 AM
    what's the most straightforward way to configure path aliases in Cypress 7+ ?
  • u

    user

    08/09/2021, 10:15 AM
    eg.
    '@/pages/*': 'cypress/pages/*'
  • u

    user

    08/11/2021, 6:44 AM
    Hello, I have implemented Sign up the flow with the Google Client API js library. The library creates a new window in the browser, then after the user has granted permissions I perform certain logic such as update global application state, redirect to the private user page, etc. I tried to follow this example, I got an access_token and id_token, although it doesn't quite fit for my use case: https://docs.cypress.io/guides/testing-strategies/google-authentication#Google-Developer-Console-Setup I'd like to create a user with Cypress without stubbing the response. Please help me to figure out how to perform this operation.
  • w

    wooden-parrot-13301

    08/12/2021, 6:03 PM
    Hello ppl, i was merging the cypress and jest codecovs and now when i make
    cy.visit('/')
    i get this:
    Uncaught Error: Module build failed: Error: ENOENT: no such file or directory, open '.../node_modules/punycode/punycode.js'
    somebody has a clue for what is this?
  • r

    rough-nightfall-90576

    08/12/2021, 7:43 PM
    Within an app I'm testing, there is a location share request from the Google api. I am trying to either disable it, or auto-accept it so it doesn't pop up. It appears this confirmation box is in the test runner and not on the test browser so I don't think I can interact with it in a on(before.browser.launch) hook. Is there a way to set that for running the test in the console? I'm guessing this isn't a problem with cypress run?
  • a

    ambitious-photographer-75673

    08/13/2021, 11:16 AM
    hello everyone, just a silly question: how do I get all arguments that stub wa called with?
  • a

    ambitious-photographer-75673

    08/13/2021, 11:17 AM
    i am asking that because my stub receives a huge array of tracking data, which may consist other arrays, objects, strings, etc.
  • a

    ambitious-photographer-75673

    08/13/2021, 11:17 AM
    and I need to assert these data
  • l

    loud-policeman-30507

    08/13/2021, 3:56 PM
    I can't seem to find docs on cy.stop()
  • b

    boundless-jackal-97384

    08/16/2021, 1:39 PM
    hello guys, i need some help with cypress dashboard i'm trying to get the videos , and I'm want to see the videos that generate on the test dashboard on cypress, but it gives an error, or it only takes 1 second of video and I can't open it... the error that appears is the following: The media could not be loaded, either because the server or network failed or because the format is not supported does anyone have any idea what it can be?
  • m

    melodic-artist-46273

    08/17/2021, 3:02 AM
    Does anyone know if there is a way to compare two aliases against each other? I have in the image two values that I wrap in aliases. The first one I get and then perform some actions. Then I get the element attribute in the same spot as the first one, but this time it should be different. I need to assert that it is different.
  • m

    melodic-artist-46273

    08/17/2021, 3:09 AM
    Here is the code that does all the work to get the output pictured above.
    Copy code
    javascript
    //Gets the ID of the second element that has an ID that ends with '-input'.
            cy.get('[title]').eq(6).then(elem => {
                let workflowID = elem.attr('title');
                cy.wrap(workflowID).as('workflowID')
                })
            cy.get(':nth-child(2) > #column0 > .vasion-icon > .vasion-checkbox > .pointer').click()
            cy.get('#home-inbox-actions-button').click()
            cy.get('#first-list > li:nth-child(1)')
                .contains('Approve')   
            cy.get('#first-list > li:nth-child(1)').click()
            cy.get('#confirm-button > button > div > div')
                .should('be.visible')
            cy.get('#confirm-button > button > div > div').click()
            cy.wait(5000)
            //Check to make sure the previously assigned alias doesn't exist anymore. i.e. The id found above no longer is in the element found below.
            cy.get('[title]').eq(6).then(elem => {
                        let nextWorkflowID = elem.attr('title');
                        cy.wrap(nextWorkflowID).as('nextWorkflowID')
                })
            cy.get('@workflowID')
            cy.get('@nextWorkflowID')
        })
  • m

    melodic-artist-46273

    08/17/2021, 3:10 AM
    So what I need to do now is compare the aliases "workflowID" to "newWorkflowID".
  • m

    melodic-artist-46273

    08/17/2021, 1:36 PM
    @here
  • r

    ripe-plastic-20004

    08/17/2021, 1:38 PM
    Hi @User . I think this could help you: https://glebbahmutov.com/blog/avoid-cypress-pyramid-of-doom/
  • r

    ripe-plastic-20004

    08/17/2021, 1:48 PM
    you can access your aliases using this.aliasName. Make sure you aren't using an arrow function on your 'it' block. It could be something like this:
  • m

    melodic-artist-46273

    08/17/2021, 2:15 PM
    So I'm replacing the
    Copy code
    javascript
    cy.get('[title]').eq(6).then(elem => {
                let workflowID = elem.attr('title');
                cy.wrap(workflowID).as('workflowID')
                })
    and
    Copy code
    javascript
    cy.get('[title]').eq(6).then(elem => {
                        let nextWorkflowID = elem.attr('title');
                        cy.wrap(nextWorkflowID).as('nextWorkflowID')
                })
    blocks with the
    Copy code
    javascript
    cy.get('[title]').eq(6).invoke('attr', 'title').as('workflowID')
    and
    Copy code
    javascript
    cy.get('[title]').eq(6).invoke('attr', 'title').then(nextWorkflowID => {
                expect(this.workflowID).not.equal(nextWorkflowID);
            })
  • m

    melodic-artist-46273

    08/17/2021, 2:21 PM
    replacing those blocks gives me an error
  • m

    melodic-artist-46273

    08/17/2021, 2:32 PM
    @User am I understanding that right?
  • r

    ripe-plastic-20004

    08/17/2021, 2:37 PM
    I thought it would work. Looking at Gleb's article, maybe it's because of the use of the arrow function in the 'then'. Maybe it works changing this, what do you think?cy.get('[title]').eq(6).invoke('attr', 'title').then(function (nextWorkflowID) { expect(this.workflowID).not.equal(nextWorkflowID); }
  • m

    melodic-artist-46273

    08/17/2021, 2:43 PM
    @User
    Copy code
    javascript
    cy.get('[title]').eq(6).invoke('attr', 'title').as('workflowID')
            cy.get(':nth-child(2) > #column0 > .vasion-icon > .vasion-checkbox > .pointer').click()
            cy.get('#home-inbox-actions-button').click()
            cy.get('#first-list > li:nth-child(1)')
                .contains('Approve')
            cy.get('#first-list > li:nth-child(1)').click()
            cy.get('#confirm-button > button > div > div')
                .should('be.visible')
            cy.get('#confirm-button > button > div > div').click()
            cy.wait(5000)
            //Check to make sure the previously assigned alias doesn't exist anymore. i.e. The id found above no longer is in the element found below.
            cy.get('[title]').eq(6).invoke('attr', 'title').then(function (nextWorkflowID) {
                expect(this.workflowID).not.equal(nextWorkflowID);
            }
    Throws an error
  • m

    melodic-artist-46273

    08/17/2021, 9:35 PM
    I got it to work!
  • m

    melodic-artist-46273

    08/17/2021, 9:35 PM
    Thanks for your help @User
  • m

    melodic-artist-46273

    08/17/2021, 9:37 PM
    Copy code
    javascript
    cy.get('[title]').eq(6).then(elem => {
                const txt = elem.text()
                cy.get(':nth-child(2) > #column0 > .vasion-icon > .vasion-checkbox > .pointer').click()
                cy.get('#home-inbox-actions-button').click()
                cy.get('#first-list > li:nth-child(1)')
                    .contains('Approve')
                cy.get('#first-list > li:nth-child(1)').click()
                cy.get('#confirm-button > button > div > div')
                    .should('be.visible')
                cy.get('#confirm-button > button > div > div').click()
                cy.wait(5000)
                cy.get('[title]').eq(6).should(elem2 => {
                        expect(elem2.text()).not.to.eq(txt)
                })
  • r

    ripe-plastic-20004

    08/17/2021, 9:38 PM
    great! Too bad you couldn't solve it with aliases. But as long as it works, great!
  • m

    melodic-artist-46273

    08/17/2021, 9:38 PM
    Now I'm onto another test. I need to figure out how to check just the first character of a string in a .should('have.value', '2/78')
  • m

    melodic-artist-46273

    08/17/2021, 9:39 PM
    That's what I thought at the end....hahaha
  • r

    ripe-plastic-20004

    08/17/2021, 9:51 PM
    Hope it works this time, haha: cy.get('locator').invoke('text').then(elementText => { expect(elementText.charAt(0)).to.be.equal('value expected') });
1...303132...252Latest