[fleXive] uses Selenium Remote Control to launch browser tests in TestNG, which potentially allows to automatically test a [fleXive] application under a variety of browsers with a single test case.
 | For a quick manual overview of the [fleXive] component library, some static test pages exist under /flexive/adm/test/ (link on localhost:8080 ). |
Browser test setup
For running the browser tests, first thing you need to do is install a recent Selenium snapshot. At the moment of writing, the latest release did not work, this snapshot
did. Newer snapshots are available here
. Extract the files from this archive to a local directory.
Launch selenium server
You can then launch the server in the selenium/selenium-server-0.9.2-SNAPSHOT directory with
java -jar selenium-server.jar -port 7983
(set the port to any desired value, 7983 is the current default for flexive browser tests).
On Ubuntu, you need to perform additional setup to allow testing in firefox:
- Create a symbolic link to firefox-bin:
cd /usr/bin
sudo ln -s ../lib/firefox/firefox-bin .
- You also have to add /usr/lib/firefox to your LD_LIBRARY_PATH, since Selenium does not work with Ubuntu's firefox startup script. Create a shell script to do this automatically:
#!/bin/sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/firefox
cd <PATH_TO_SELENIUM>/selenium-server-0.9.2-SNAPSHOT
java -jar selenium-server.jar -port 7983
- Execute this shell script using sh <script_name>.
Set test environment properties
You need to set the environment properties (i.e. the Selenium server URI and the local test domain) in a file called browser.properties in /src/framework/tests/java/com/flexive/tests/browser/browser.properties. Create a new file and paste the contents of browser.properties.sample in the same directory. Enter your selenium server address and port, as well as the base URL for accessing the local [fleXive] installation. A valid browser.properties might look like this:
tests.browser.selenium.host=localhost
tests.browser.selenium.port=7983
tests.browser.selenium.baseUrl=http:
 | Writing your own browser tests
When writing browser tests for your own [fleXive] application, you might want to use another properties file or hardcode the parameters in the testcase. You can supply the properties file name as well as other parameters to the base class of all [fleXive] browser tests, com.flexive.tests.browser.AbstractSeleniumTest. |
Run the [fleXive] browser tests
The flexive3 application has to be up and running on your application server. You also have to add the flexiveTest datasource to your datasources, e.g. for JBoss
<xa-datasource>
<jndi-name>jdbc/flexiveTest</jndi-name>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<!-- Note: "&" has to be used instead of "&" for parameters -->
<xa-datasource-property name="URL">jdbc:mysql:&characterEncoding=utf8&characterResultSets=utf8</xa-datasource-property>
<user-name>root</user-name>
<password>a</password>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<no-tx-separate-pools/>
<!-- This disables transaction interleaving (which BTW, most DB vendors don't support) -->
<track-connection-by-tx/>
<isSameRM-override-value>false</isSameRM-override-value>
<!--pooling parameters-->
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<!-- pooling criteria. USE AT MOST ONE-->
<!-- If you don't use JAAS login modules or explicit login
getConnection(usr,pw) but rely on user/pw specified above,
don't specify anything here -->
<!-- If you supply the usr/pw from a JAAS login module -->
<security-domain/>
<!-- if your app supplies the usr/pw explicitly getConnection(usr, pw) -->
<application-managed-security/>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</xa-datasource>
Before the first browser test run, you need to setup the test database using
 | Beware of flexive caching
Don't reset the test database without restarting the application server. [fleXive] caches lots of data retrieved from the database, and resetting the database of a running instance will likely wreck [fleXive] |
To execute the browser tests, go to the [fleXive] installation directory and execute
ant db.noupdate tests.groups -Dtests.groups=browser
If all goes well, the browser tests will connect to the selenium server and run its tests in a local browser window. Also check the selenium server console for errors.
Hi, did you know selenium doesn't continue to test case after it finish with selenium.start(), this is the snippet:
@BeforeMethod(alwaysRun = true)
public void setup()
{
LOGGER.info("<< Setup Test >>");
try
catch (Exception e)
}
selenium only run until selenium.start() command and do nothing after that.
thank u.
Sai
Hi Sai,
did you start Selenium server before running the tests? It's not clear from the code snippet you gave, but you have to execute the test cases on the DefaultSelenium instance you created in the call above.
Daniel