Tests cannot find the Search Button 3.x QA

Hi all,

I have been working on (ticket) Improving the Search E2E test.

The changes done to the workflow

  • Creates a new patient with a random name.
  • Search for the newly created patient.
  • Deletes the newly created patient at the end of the test.

I faced a blocker while working on this issue. The test cannot find the Search Button most of the time. But sometimes (1/20) it finds the button and the test passes.

Steps taken to solve this issue Result
Finding the button using a different attribute Fail
Setup patient-search-app, add an id to the button and test locally Fail

cc: @jayasanka @kdaud

what happens when you get rid of cy.log()?

26 | cy.log('Searching for ${patientName]');

Same result.

@kumuditha which server are you using at the moment?

Currently using: https://openmrs-spa.org/openmrs/spa

As of now I am not in position to reproduce the issue on my side due to what @piumal1999 reported here

@kumuditha are you in position to login into the server successfully?

1 Like

The problem is in the condition syntax. For such conditions, every symbol counts. You either copy-paste the text from the actual element or add a selector to assert the element by selector for future cases. By default Cypress assumes whenever you cy.get an element - for that element to exist. It will wait around until it does exist or it will time out. If it times, the test fails.

If you want Cypress to wait until the element DOES NOT EXIST, you simply add that as an assertion e.g.


Hope that helps.

1 Like

Yes, but I’m using

  • Username: admin2
  • Password: Admin123

admin account doesn’t work.

This thread could be helpful : https://openmrs.slack.com/archives/CHP5QAE5R/p1639386512452900

1 Like

Thank you! @jwnasambu, I’ll try it.