When I think of Tosca, I think of Italian Tuscany...Enchanting hilly landscapes, majestic green slopes with olive trees, sun-drenched meadows with magical cypress trees and picturesque village views. All very nice, but unfortunately it has nothing to do with a low-code “test platform” or test tool like Tosca. Now I don't want to bother you with the history behind Tosca, but of course about what Tosca can do. Below a first in the series “Do you know that Tosca...”
Do you know that with Tosca (Commander), you can run Selenium scripts? I don't need to tell the seasoned test automation specialist that Selenium is an "all-in-one" web automation tool. “All-in-1 tool” is a big word, because Selenium focusses on automating browsers (web applications), but the combination of “web driver”, “IDE” and “Grid” still makes Selenium a very popular “tool” among testers. Mainly because of the support for browsers other than Firefox, the applicability in different operating systems and the compatibility with various CI/CD tools such as Jenkins.
But why should I use Selenium when I can use Tosca for web automation? Because it's possible! Many well-known test (automation) tools have Selenium as a “base”. Just think of Protractor, Robot Framework or Fitnesse. Furthermore, in some projects we see that people prefer to work with open source automation tools such as Selenium, whether or not developed in Java or another object-oriented programming language. In addition, well-known cloud-based test solutions from Tricentis, such as TestProject and Testim, also use “Selenium-based” engines. So why not?
How do I implement Selenium scripts in Tosca? If you have created a new workspace in Tosca Commander, you will undoubtedly have heard of the “Standard modules” (see figure 1).
In subfolder “TBox Automation Tools” you will find subfolder “Selenium” with 2 modules. In general, the Selenium modules support the execution of the Selenium test scripts. Usually, the Selenium test scripts concerned, are already part of an existing (test) project or are components that can be automated, such as unit tests. Regarding the unit tests, both Junit and Nunit are supported. Affected modules can be used to launch Selenium test cases directly from Tosca Commander. The “Start Selenium Server” module is used to start up your Selenium server. And the “Run Selenium Scripts” module is used to run the Selenium test scripts. For the Selenium server, versions 1, 2 and 3 are currently supported, and please note that the default port number 4444 should not be in use by another application or server. Let's start with a test scenario. Suppose you have a Selenium server path that you want to call and that you want to use to run the test cases. Then you have to specify the "TestStepValue" for the Selenium server path, i.e. the location to the Selenium server .jar file. See an example below:
Once you've set up the Selenium .jar path, it's time to specify the test scripts to call. For this we need the "Run Selenium Scripts" module. This is the module responsible for calling the Selenium scripts. Furthermore, suppose you want to run the script with a class called "Login_Check" and which has different Test Methods such as "Validate_Username" and "Validate_Password". Since your .jar file can have multiple test classes to run, you might be interested in running only the “prio 1” classes, for example in a regression test. In this case you will only need to specify the class name in question. In the example below, the "TestStepValue" TestClass defines that Tosca should use the TestClass "Login_Check" (see Figure 2).
That’s it! Of course you can play with different types of classes and methods. For more information about Tosca in combination with Selenium:
Published: 5 April 2022
Author: Otman Zemouri