Tuesday, February 17, 2015

ADF Faces 12c Components Demo and Test Automation

You might have noticed that I am working on a series of blog articles on using Selenium to automate testing of Oracle ADF applications. This includes work on a little framework to make this easier and a set of sample JUnit tests against the public Oracle ADF Faces 12c Components Demo.

Getting the Faces 12c Component Demo running with test automation had some challenges. I wanted to write them down here in case somebody wants to try the same. It starts by downloading the Oracle ADF Faces Components Demo from OTN. This also includes instructions on how to run this application in your integrated weblogic server, but those instructions have some caveats and are for JDeveloper 11g, not version 12c. Please follow the instructions below as an alternative (I've marked the differences with the normal Oracle instructions and included screenshots at the end).

In the end this needed more work than I expected, so I also offer the fixed versions for download. If anyone from Oracle feels that this is a problem please contact me and I'll remove the download and you can follow the instructions below to create your own fixed version.

If you want to start from the downloads from Oracle and not use my fixed versions you would have to follow these steps:
  1. Download the ADF Faces 12c Components Demo WAR file, but don't unpack it.
  2. Start JDeveloper 12.1.3
  3. Instructions updated from 11g: Choose File > New > From Gallery from the menu to create a new application. Select General > Applications in the tree and select Custom Application as application type and press Ok.
  4. In the Create Application dialog type adffacesdemo as the application name, select a directory, leave the rest of the options alone and press Finish. This creates new application workspace and project.
  5. Instructions updated from 11g: The default created project is not needed and you may delete the project. Right click it and select Delete Project. In the subsequent dialog choose to not only delete the project form the application but also delete it from disk.
  6. Instructions updated from 11g: In the now empty workspace choose File > New > From Gallery from the JDeveloper menu. In the list of items select Projects and on the right hand side Project from WAR and press Ok. In the next dialog provide a name for the project, e.g. adffacesdemo, and keep the directory information. On the second panel, use the file browser to select the downloaded ADF Faces demo WAR file and finish the wizard.
  7. Double click onto the project node to open the project properties and select the Run > Debug > Profile option. Press the Edit button and select the Tool Settings. In the Before Running section, uncheck the Make Project and Dependencies option and close the dialog pressing Ok.
  8. Extra step added by me: Unfortunately some files are missing from the exploded WAR which will result in javascript errors and missing images.
    • Manually copy the META-INF directory from the src directory to the classes directory so you end up with classes/META-INF
    • Copy the src/oracle/adfdemo/view/js directory (and all of its subdirectories) to classes/oracle/adfdemo/view/js
    • Copy the two .properties files from src/oracle/adfdemo/view/resource to classes/oracle/adfdemo/view/resource
    • Copy the src/oracle/adfdemo/view/resource/fileExplorer directory and the .properties file it contains to classes/oracle/adfdemo/view/resource/fileExplorer
    • Copy all xml file from src/oracle/adfdemo/view/components/rich/tageditor to classes/oracle/adfdemo/view/components/rich/tageditor
    • Copy the xml and csv file from src/oracle/adfdemo/view/feature/rich/diagram/data to classes/oracle/adfdemo/view/feature/rich/diagram/data
    • Copy the src/oracle/adfdemo/view/feature/rich/dvt/data/election directory to classes/oracle/adfdemo/view/feature/rich/dvt/data/election
    • Copy all xml files from src/oracle/adfdemo/view/feature/rich/hv to classes/oracle/adfdemo/view/feature/rich/hv
  9. Extra step added by me: To be able to use test automation on this ADF sample application, enable automation by opening public_html/WEB-INF/web.xml in JDeveloper and remove the comment markers around the existing oracle.adf.view.rich.automation.ENABLED context parameter.
    For test automation to work you also have to copy JDEV_HOME/oracle_common/modules/oracle.adf.view_12.1.3/adf-richclient-automation-11.jar to the  public_html/WEB-INF/lib directory of the project.
  10. Extra step added by me: As a final step I prefer a simple URL when running the application. Double click the project to open the project properties. In the Java EE Application section change both the application name and context root to adf-richclient-demo
  11. Finally, expand the project and select index.jspx under the Web Content node. Choose Run from the right mouse context menu.

Screenshots of these steps are below for your reference:
New Gallery dialog to create Custom Application
Create Custom Application dialog
Delete the default project
Delete the default project from disk
Create new project from WAR
Step 1 of importing WAR
Step 2 of importing WAR
Disable Make Project in Run Profile
Uncomment/activate existing oracle.adf.view.rich.automation.ENABLED

Add adf-richclient-automation-11.jar to public_html/WEB-INF/lib
Setting application name and context root in project properties

This post is part of a series on how to get Selenium to work with Oracle ADF.

No comments:

Post a Comment

Comments might be held for moderation. Be sure to enable the "Notify me" checkbox so you get an email when the comment is accepted and I reply.