Creating a UI Test

  1. Create a Java class in your module, and put it in the "test-src/com/onenetwork/<module>/selenium/" directory. The class name should end in "UITest". The following is a simple example of a UI test.

    package com.onenetwork.showcase.selenium;
     
    import org.junit.*;
    import com.onenetwork.platform.tools.test.ui.CommandCenter;
    import com.onenetwork.platform.tools.test.ui.components.Tab;
     
    public class ExampleUITest {
    private static CommandCenter cc;
    // Log into Command Center as "ShowcaseUser".
    @BeforeClass
    public static void setUp() {
    cc = new CommandCenter();
    cc.login("ShowcaseUser", "password");
    }
    // Open the Kitchen Sink tab by going to Basic Components > Kitchen Sink.
    // Then verify the tab's name is correct.
    @Test
    public void test() {
    Tab tab = cc.openTabFromMenu("Basic Components", "Kitchen Sink");
    Assert.assertEquals("Kitchen Sink", tab.getTitle());
    }
    // Log out of Command Center.
    @AfterClass
    public static void tearDown() {
    cc.logout();
    }
    }

  2. To run your UI tests, you need to have Platform Server running and your data already loaded, because it needs to log into NEO to simulate a user's actions. Once Platform Server is running, execute "ant ui-test" within your module. To run a single test, you can optionally provide a parameter "-Duitest=<testname>". You can also run them using JUnit inside Studio, but that might require adding the Selenium JARs to your module's ".classpath" file. As you can see from the image below, the openTabFromMenu() call in the example test will tell Selenium to traverse each menu in NEO until it reaches the last item, which it clicks to open the tab.

    images/download/attachments/144836447/uitest-version-1-modificationdate-1670860439000-api-v2.png