Robot Framework with Java - POM pattern

Dear Community,

I want to use POM pattern for UI tests.
I see examples where pages might have .py or .robot extension.
In my case I believe it will be .java.
But how can I import my page into the test suite file.
Any suggestions please?

There are no many resources of RF + Java usage on the Internet, unfortunately

Hi,

POM is nothing Java specific. So, if you can choose, I recommend creating POMs in Python.

Getting Java code to work in Robot Framework is quite an effort. I only have used Remote server library many years ago. I hear there are other ways, but I never had the use case.so I don’t want to spread half rumors. Maybe somebody else knows better.

Also take in to account that using Java-POMs in Robot Framework will make you loose some benefits of using RF, like indepth debugging or using robust UI automation libraries that are already available (i.e. SeleniuemLibrary or Browser library). That’s probably the reason there is not much resource on RF + Java out there.

I’d curious to learn, how you continue.

Regards,
Markus

3 Likes

If your java files contain only the objects locators, for Web tests, the best you can do is to convert them to Python and use in a variables file.

Robot Framework no longer can access Java objects directly with Jython (even so you would need to have .class or a .jar files). These days when using Java classes, it needs to use RobotRemote server.
My favorite example of this is SikuliLibrary which is based in SikuliX, made in Java.
Take a look on the README of SikuliLibrary.

1 Like

Thank you guys, @Noordsestern , @HelioGuilherme66
I need to think which approach to follow. I have a requirement that it should be Java.

If the requirement is that your POM code needs to be in java, robot is not an option here. While you could inject robot into mix, it would not make sense as it would add quite a lot of overhead to get the setup working - imho…

2 Likes

I see your point
Thanks @rasjani

I would question that requirement. What (user) problem is being addressed by the POM being in Java? What is the business value of that requirement?

Odds are, it’s not a requirement but rather a technical preference or a policy. If it’s a policy, I would discuss the policy in relation with the use of Robot Framework.

2 Likes

Yes, that’s a policy.
Python is not a main technology in the company. After visiting the RF conference want to check what are the benefits of using RF. It is mentioned in the RF docs that Java is supported that’s why I started this POC.

Jython was one of the environments where you could run robot framework but jython development was not catching up when python transitioned from python 2 to python 3. Jython is afaik not fully compatible with “even” Python 3.8 (see Jython 3 Features and MVP | Jython) which is the oldest currently supported python version.

Another alternative for running python code/robot on Java VM is GraalVM. I did have a brief talk with @pekkaklarck some time ago and he mentioned that at least some XML code in RF didnt work correctly on top of GraalVM compared to pure python Robot Framework. This was maybe around 6-8 months ago. Maybe things have changed ? Point being, if you are asking and not trying out and capable of solving issues on your own – my advice still is “robot is not an option here.”. If you are capable developer, I’m 100% things can be fixed but that most likely means you need fix something in core RF and proably even some libraries.

Now, if you are willing to run older robot framework and libraries that do not utilize anything newer than python 2.7, you still can run robot just fine on top of Jython.

1 Like

If there is little to no Python competence within the company, I would not advise Robot Framework unless what you’re doing is mainstream / standard things.

The power of Robot Framework is in it’s extensibility, which can be done in Python. If you’re not going to do that, you’re going to be limiting yourself. That may be fine, it may not be.

As for the POM, you can use that pattern just fine with pure Robot Framework. There’s no need for Java / Python for something simple and mostly static like a POM.