Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Richard_Büffing
Participant

Introduction

In this blog we are going to set up the integration between SAP Cloud ALM and a local Selenium WebDriver.
A Selenium Web Driver is basically a server in charge of executing so called Selenium scripts.
This constellation will be used in the setup of Synthetic User Monitoring in SAP Cloud ALM

Architecture Overview

In Synthetic User Monitoring you need a so called "Runner" which, in simple terms, is a robot that executes your prepared selenium scripts.
These runners are based on the Selenium WebDriver infrastructure.
So you will need such a web driver infrastructure and for that you have two options:
1. A cloud based 3rd party WebDriver provider.
2. A local on-premise Selenium WebDriver

If you are interested in using third party Selenium providers you can read my previous article
The application to be monitored is shown as a local web application, but it could really be any web application including cloud based ones such as SAP BTP.
The advantage of using a local Selenium WebDriver is that you can monitor on-prem web applications as well as cloud based web applications.
In this guide we will focus on the local Selenium WebDriver, depicted in the lower half of this picture.

Richard_Bffing_0-1715242814343.png

Prerequisites

In order to follow this setup you need the following things:

  1. SAP Cloud Connector up and running (I am not going into this topic as there are plenty of excellent guides out there.)
  2. A local server with a Java Runtime engine (you also need a web browser installed on the server for this option)
    or
  3. A local server capable of running Docker containers

There are other options than Java or Docker for running Selenium WebDrivers, but in this tutorial I'm just going to stick with those two.

Setup of On-Prem Selenium WebDriver

Option 1: Java based Selenium WebDriver

Get the latest Selenium WebDriver for Java from the official download site:
https://www.selenium.dev/downloads/

Go down to the section called "Selenium Server (Grid)", from there download the server jar file

For example: selenium-server-4.20.0.jar

Copy the jar file to a directory of your choice, then run the following command.
Unix/Linux:

 

java -jar .\selenium-server-4.20.0.jar standalone --selenium-manager true &

 

Windows (Powershell):

 

Start-Process -NoNewWindow java "-jar .\selenium-server-4.20.0.jar standalone --selenium-manager true"

 

For more commandline options including starting the server with a different port or with SSL you can refer to this site:
https://www.selenium.dev/documentation/grid/configuration/cli_options/

If you did it right, you should be able to call the url: http://localhost:4444 and see something like this:

Richard_Bffing_0-1715245502531.png

Option 2: Docker based Selenium WebDriver

For more information on the Selenium Docker Image you can refer to the folowing resopurces:
https://hub.docker.com/r/selenium/standalone-chrome
https://github.com/SeleniumHQ/docker-selenium

For this option you need Docker installed on your Linux server or Docker Desktop on your Windows server.
In order to optain the Docker image file execute the following command on cour commandline:

 

docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:latest

 

This will automatically download the Docker image file from the Docker Hub repository and start a local container.

Note:
You only need the docker run command the first time. Do not use the docker run command every time for starting as it will always create a new container.
Instead use the docker ps command and docker start command:

 

docker ps -a

 

This will give you the container id:

Richard_Bffing_0-1715247189850.png

Then use this id to start the container again:

 

docker start <containerid>

 

 

Again if you did everything right, you should see this from the local url http://localhost:4444

Richard_Bffing_1-1715247406375.png

Notice that in this case there's only one browser available, depending on the docker image you chose.

Settings in SAP Cloud Connector

As mentionned before, in order to connect SAP Cloud ALM to your local Selenium WebDriver you must have registered the SAP Cloud Connector in the subaccount or your SAP Cloud ALM.
Once SAP Cloud Connector is available in the Subaccount you have to expose the local server and port to it.

Log on to your SAP Cloud Connector, then choose the subaccount.
Then from the lefthand menu choose "Cloud to on Premise" and click on th + button.

Richard_Bffing_3-1715248059276.png

Choose "Non-SAP System" and click Next

Richard_Bffing_0-1715248262814.png

 

Choose the protocoll that your Selenium serve is running on and click Next

Richard_Bffing_1-1715248371098.png
Enter the fqdn or ip of your local selenium server and the port

Richard_Bffing_2-1715248508089.png
Note: If there's a firewall between yout SAP Cloud Connector and your local server, then you obviously have to allow traffic with that port to it.
Then indicate the virtual host name and port as you want it to be available later on in Synthetic User Monitoring

Richard_Bffing_0-1715248902046.png
If you want users authenticated on your BTP to be propagated to your local server then enable this.
Note: This really only makes sense when you are running your Selenium WebDriver asking for user/password and the user is the same as you log on to your BTP (Cloud ALM).

Richard_Bffing_1-1715249197078.png


Richard_Bffing_5-1715249478213.png

Now add a path to the newly registered virtual server

Richard_Bffing_7-1715249864411.png

Richard_Bffing_9-1715250080941.png

In this example I chose "/" and all sub paths, please make sure you consider your own safety requirements.
Once the path is registered the status of the virtual host will become green.

Richard_Bffing_8-1715250046313.png
The result in your SAp Cloud ALM subaccount should look like this:

Richard_Bffing_0-1715250950561.png

Setup in SAP Cloud ALM

The setup in of Synthetic user monitoring is pretty much the same as in my previous article on Setting up Synthetic User Monitoring , so I'm not going to repeat everything here.
However there's one major difference and that is, now you have to register a local runner.

Registering a local Runner

From the main page choose "Operations" then "Synthetic User Monitoring":

Richard_Bffing_1-1715251262869.png
From the SUM main page click on the setting button:

Richard_Bffing_2-1715251424011.png
From the righthand side menu expand "Runners" the click on the edit button:

Richard_Bffing_3-1715251849695.png
Click on the "Add" button

Richard_Bffing_4-1715251930155.png
On the next screen enter a name, the type "On Premise" and the virtual host that we registered using SAP Cloud Connector.

Richard_Bffing_5-1715252173426.png
Note: If you set up your local Selenium WebDriver without username/password you can just enter "None" and any bogus password.
Result, the Runner status should become green like this:

Richard_Bffing_0-1715252627465.png

Now it is ready to use in the scenarios for further setup.

Conclusion

We have learner how to install a local Selenium Server, so called WebDriver.
Then we have set up SAP Cloud Connector to give us a virtual hostname pointing to our local server.
Finally we have registered a runner pointing to our local Selenium Server through SAP Cloud Connector.
I hope you find my article usefull. I would be happy if you would share your thoughts and I'm happy to assist with any questions to my best abilities.

Labels in this area