How to write tests for Reference Application UI Framework
...
You can use http://int-refapp.openmrs.org/ (or others sites) instead of localhost, if you cant or dont want to use Vagrant (https://wikiopenmrs.openmrsatlassian.orgnet/wiki/x/CIC3Ag-wRYAQ)
You can use Chrome browser instead of Firefox browser. New versions of Firefox work incorrectly on Windows 7 and 8, so you must use old Firefox version, e.g. 15. Before committing not forget to ignore pom.xml
...
We use VisitTest as an example test (https://github.com/openmrs/openmrs-distro-referenceapplication/blob/master/ui-tests/src/test/java/org/openmrs/reference/StartVisitTest.java) and PatientDashboardPage as an example page (https://github.com/openmrs/openmrs-distro-referenceapplication/blob/master/ui-tests/src/maintest/java/org/openmrs/reference/page/PatientDashboardPageHomePage.java)
Tests are basically composed of:
...
We can take an element from page by his id. Example code for this table:
private static final By LOCATION_LIST = By.id("sessionLocation");
How to take the List of "li" elements from table
Example code for this table:
WebElement locationList = driver.findElement(LOCATION_LIST);
List<WebElement> locationCollection = locationList.findElements(By.xpath("id('sessionLocation')/li"));
locationCollection is List of WebElements - "Inpatient Ward" button, "Isolation Ward" button, etc.
...
How to get text from WebElement (locationCollection)
Example code:
return locationCollection.get(index).getText();
Where "index" is index of table element
...
Example code:
locationCollection.get(index).click();
Where "index" is index of table element
...