WaitForElement not working when changing pages

Hi all,

I’m currently trying to convert existing UI test cases in the Reference Application as detailed in the automated testing guidelines. Upon running some of the tests, I realised that the application times out at waitForElement() when navigating between pages. HomePage's goToActiveVisitPatient() is one example where the function fails.

I’m currently running Firefox 39, not sure if this is a browser problem. Do let me know if its working in other versions.

Also, can any staff member clarify whether we’re allowed to navigate pages using this current method, or have pages return the page to navigate to as specified in the automated testing guidelines?

  1. It is not allowed to instantiate classes extending Page in test classes. They must be returned from Page’s actions e.g. ActiveVisitsPage activeVisitsPage = homePage.goToActiveVisitsSearch();

Thanks all in advance!

1 Like


First of all thanks for picking up the task of converting UI tests.

Could you please be more specific which test times out and take a screenshot of the screen of your browser when it happens? Is it any existing test or code you are currently converting? If it is the latter please send a pull request so I can have a look and test it locally.

Regarding your second question. It is best practise to always implement go actions so that any page can be accessed using go actions from other pages. It mimics the way how the user interacts with the website i.e. he/she doesn’t access pages typing a url rather clicks links on pages.


I’ve attached a screenshot which I took when the test is running but is inside waitForElement, and the stack trace below, where I ran AddDiagnosisToVisitTest. As shown in the screenshot, “User572…” was not clicked as execution did not exit from waitForElement. This is just one example, but there are a number of tests relying on this method which fail as well. However, I notice that these tests were set to be ignored. Therefore, I’m unsure if waitForElement is a depreciated method which needs to be replaced as well.

So regarding the 2nd qn, instead of having a clickOn(WebElementToAnotherPage) like clickOn(ACTIVE_PATIENT), is it better to have a go function within ActiveVisitsPage, which will return the next page (ClinicianFacingPatientDashboardPage)?

Link to trace:

Btw, are there any spoiler tags here? Sorry, I’m still new to the forum here.

A post was split to a new topic: HOWTO Use “spoiler” tags in OpenMRS Talk

Thanks for the reply! Actually, I was looking for something like a spoiler button to show/hide contents, since I wanted to paste a stack trace with many lines into the post. Figured it’ll be hard to navigate through this thread if I did that.:slightly_smiling:

In that case, it’s best to provide a link to a file on gist.GitHub.com or pastebin.com. If you provide the URL on a line by itself, it will render a preview as shown above. :slightly_smiling:

1 Like

@raff I’ve submitted a pull request, do let me know if it’s ok. Thanks!