I've got a challenge in my current organization on re-using the capabilities written on javascript in our java code. Just to give a background:
We have two different automation frameworks:
- Java using maven - Uses Cucumber jvm and selenium with page object model - This is mostly maintained by testers
- Javascript framework - User cucumber js and selenium web driver - This is maintained by UI developers
The challenge here is we wanted to converge both the frameworks and re-use the capabilities between both. My idea is re-using the page objects at least elements and some helper methods between both the frameworks.
Say for an example:
- I have page elements captured in
Login.js
file and contains few helper methods like generating the random email address. - I should be able to import the
Login.js
file in my Java class and also should be able to use the page elements and helper method written in javascript.
What I found was cucumber rhino to use the capabilities from java to javascript. Whereas the other way round is not possible.
I can use java 8's scripting engine Nashorn
to load the js modules in java, but the same cannot be used if my JS modules are written using Node
. And yeah cucumber.js is node module :(
I came across Avatar js which can be used to load the node modules in the jvm. But again the Avatar does not have the support for Cucumber
. I tried and failed.
Is there any way to solve this problem?