question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cy.type() randomly failing to set text, when length of text > 5.

See original GitHub issue

Current behavior:

cy.type(‘Los Angeles, CA, USA’).should(‘have.value’, ‘Los Angeles, CA, USA’); is failing randomly in google map’s search field. Its like randomly happening. I ran 10 times and it passed 3 times only.

Screen shot: Exec Screenshot

Desired behavior:

It should set text as we expected all times.

Steps to reproduce: (app code and test code)

Code: code

describe('Location related tests', function() {
    it('should search the respective location', function() {
        cy.visit('https://maps.google.com/');

        cy.get('#searchboxinput')
            .type('Los Angeles, CA, USA')
            .should('have.value', 'Los Angeles, CA, USA');
    })
});

Versions

“cypress”: “^3.6.0”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
skoblenickcommented, Nov 12, 2019

@Bkucera I could reproduce this issue exactly as @hardikdiyora92 describes in the test case but…

I created a PR at https://github.com/cypress-io/cypress-test-tiny/pull/53 to demonstrate potentially similar, if not the same issue around the type() command. It seems to be related to 3.6.x. The AngularJS material input I am using receives partial events from type() but doesn’t react as expected.

The first test example shows it failing. The second shows that I can work around the issue in certain cases by using a click() on the component before I type. It looks like the type event isn’t setting, possibly keeping focus, when the type command starts to send events; reverting to the last clicked element and starts sending the events to that other component.

1reaction
kucebcommented, Nov 7, 2019

@hardikdiyora92 trying out the google maps example, type is working fine but the page is still loading while the text is being typed, which causes the input to briefly be blurred. You can manually verifying this by commenting out all steps but the cy.visit() and manually typing as soon as the page starts to load. If you add a .wait() before the type, the problem goes away

you could use cy.route and wait on one of the XHRs to complete before proceeding in the test

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retry-ability - Cypress Documentation
If the assertion still fails, Cypress continues retrying until the cy.find() timeout is reached. Retry-ability allows the test to complete each query as...
Read more >
cy.type() failed because this element is not visible: - You.com
Hello,. Facing the issue loading the login page in cypress test using cy.visit(). Tested in browser and url link is working correctly so...
Read more >
cy.clear() not clearing input field properly - Cypress
clear().should('have.value', '').type('random text');. It works some time and in other times it complains it does not ...
Read more >
Solve Flake In Cypress Typing Into An Input Element
Workaround using cypress-recurse # ; () => cy.get('#flaky-input').clear().type(text), ; ($input) => $input.val() === text, ; log: false,
Read more >
Bash Reference Manual - GNU.org
The term macro processor means functionality where text and symbols are expanded to create larger expressions. A Unix shell is both a command ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found