Inizia ora la tua demo e risparmia sui primi 12 mesi!


UI testing: Maveryx vs Selenium

Pubblicato da Il 30 Settembre 2021 in Blog

UI testing is a process used to test the user interface of an application, and to detect if the application is functioning correctly.

Selenium and Maveryx are two automation frameworks used to test web applications across different browsers and platforms. This means your tests run in the exact environment your users see.

They provide a set of APIs for automating browser actions (emulate user behavior).
Both supports several programming languages like Java and C#.

In this article we will compare Selenium to Maveryx using a sample application.

The web application we are testing in this example is a simple calculator implementation (

We are testing the web application by simply adding two numbers together and checking the results.

The code is well commented so you can understand what each line is doing.

We start our UI test with configuring the browser, opening Google Chrome for our tests, and navigating to the web page.

                //The URL of the calculator to be opened in the browser
                private static String calculatorUrl = "";
		//The path of the WebDriver for Chrome
                private static String driverPath = "D:/Selenium/chromedriver_win32/chromedriver.exe";
		//The Selenium web driver to automate the browser
		private static ChromeDriver chromeDriver;

		//Sets the ChromeDriver path
		System.setProperty("", driverPath);
		//Creates the Selenium web driver
                ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
		ChromeOptions chromeOptions = new ChromeOptions();
		chromeDriver  = new ChromeDriver(chromeDriverService, chromeOptions);
		//Open the calculator page in the browser

                //Sets the ChromeDriver path
		//Open the calculator page in the browser

Once on the web page, we simulate a user interacting with page elements.


Selenium WebDriver uses ‘locators’ to find web elements when testing a website. The element IDs on the page are used to identify the fields we want to enter data into.

                private WebElement firstNumberElement = chromeDriver.findElement("first-number"));
                private WebElement secondNumberElement = chromeDriver.findElement("second-number"));
                private WebElement addButtonElement = chromeDriver.findElement("add-button"));
                private WebElement resultElement = chromeDriver.findElement("result"));
                private WebElement resetButtonElement = chromeDriver.findElement("reset-button"));

Or alternatively, among various locators, XPath is widely used:

                private WebElement firstNumberElement = chromeDriver.findElement(By.xpath("//input[@placeholder='First Number']");

Using locators, you might develop a test script that type in the text box with an id of “first-number”. Now, let’s say that the development team does a redesign, and the id for the text box changes to ” first_number” (simply replacing “-“ with “_”). Your test is broken, even though the functionality didn’t change one whit. The Selenium test is brittle.


Maveryx doesn’t use neither ‘locators’ nor XPath; any “visual” identifier like caption and tooltip, or html attribute can be used to identify the fields we want to enter data into.

                GuiText firstNumber = new GuiText("First Number"); //using caption
	        GuiText secondNumber = new GuiText("Second Number");
	        GuiText result = new GuiText("result");
	        GuiButton add = new GuiButton("Add");
	        GuiButton reset = new GuiButton("Reset");


		GuiText firstNumber = new GuiText("first-number"); //using the attribute "id"

Through this approach you don’t have to build any locator or use XPath query.
The UI objects to test are automatically retrieved at runtime by applying several searching algorithms.
If the text field changes from “First Number” to “First-Number” or “First_Number”, Maveryx is able to locate it without changing the script.

Other functions here are basically simulating a user entering numbers into the calculator, adding them up, waiting for results, and moving on to the next test.

                //Click the reset button;

		//Clear text box
		//Enter text
		//Check if the text was entered
                assertEquals(Integer.toString(number), firstNumberElement.getAttribute("value"));

		//Clear text box
		//Enter text
		//Check if the text was entered
                assertEquals(Integer.toString(number), secondNumberElement.getAttribute("value"));

		//Click the add button;

		//Check for the result
                assertEquals(Integer.toString(firstNumber + secondNumber), resultElement.getAttribute("value"));

                //Click the reset button;

		//Enter text (automatically clear the text box)
		//Check if the text was entered
		assertEquals(Integer.toString(number), firstNumber.getText());

		//Enter text (automatically clear the text box)
		//Check if the text was entered
		assertEquals(Integer.toString(number), secondNumber.getText());

		//Click the add button;

		//Check for the result
                assertEquals(Integer.toString(firstNumber + secondNumber), result.getText());

By this article, the main difference in UI testing between Selenium and Maveryx is in the UI object identification.

Selenium uses locators and XPath, while Maveryx uses a simple string like caption, id, value, name, placeholder, etc.

For example, to identify the “Add” button by caption, using Selenium you have to write:

                private WebElement addButtonElement = chromeDriver.findElement(By.xpath("//button[@type='submit' and contains(., 'Add')]"));

while, with Maveryx you have to simply write:

                GuiButton add = new GuiButton("Add");

Moreover, Maveryx automatically uses partial matching and fuzzy matching algorithms to locate the UI objects in a transparent way for the user.

For example, in case of the “First Number” text box you can alternatively use:

		GuiText firstNumber  = new GuiText("First Number"); //(exact match)
                GuiText firstNumber  = new GuiText("first number"); //(exact match but lowercase)
		GuiText firstNumber  = new GuiText("First"); //(partial match)
		GuiText firstNumber  = new GuiText("FirstNumber"); //(fuzzy match)

Attached you will find the source code both for Selenium and Maveryx test scripts. Enjoy.