How to write Automated UI test i.e E2E test for custom plugin for oxygen XML editor

Oxygen general issues.
tarinisunil
Posts: 9
Joined: Thu Mar 04, 2021 9:19 am

How to write Automated UI test i.e E2E test for custom plugin for oxygen XML editor

Post by tarinisunil »

Hi,

we have a complex plugin for oxygen XML editor. There are many UI flows involved in there and each cycle requires manual effort. Is there a way we can automated the UI flow test (E2E) e.g opening the connection pop (for our plugin for login) etc
Since https://www.oxygenxml.com/doc/versions/ ... tests.html only talks about the junit tests , we need some E2E flows as well.
Any help would be great

Regards
Tarini
adrian_sorop
Posts: 73
Joined: Wed Jun 22, 2016 2:48 pm

Re: How to write Automated UI test i.e E2E test for custom plugin for oxygen XML editor

Post by adrian_sorop »

Hi,

Let me check if I understand correctly: you've created a custom Oxygen plugin. You have automated tests for the plugin functionality and now you want to add some integration tests (if I remember correctly, in non-javascript world the E2E testing is called integration testing).
Using the flow from https://www.oxygenxml.com/doc/versions/ ... tests.html will open the entire Oxygen application.

If you want to actually click different UI components, you can use java.awt.Robot. The downside of this methiod is the Robot itself: since it takes control of the of native system input events, moving the mouse while the test is running the Robot continues clicking, sometimes on the wrong application. But, of you're running the tests on a CI/CD server, this should not be a problem.
The other approach is to invoke actions programatically "taking" them from the toolbars were added, using shortcuts, etc.
If you want to discuss more, a concrete example would be better.

Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
tarinisunil
Posts: 9
Joined: Thu Mar 04, 2021 9:19 am

Re: How to write Automated UI test i.e E2E test for custom plugin for oxygen XML editor

Post by tarinisunil »

Hello Adrian,

thankyou for your reply. We are looking at integration testing .
An example would be as follows.
Integration Test Case: Open settings dialog, enter credential and user is able to login and fetch Repository.

On opening oxygen author we create a panel from our plugin
Image Shared in Adobe Cloud : https://acrobat.adobe.com/link/track?ur ... ee5a3760f5

User clicks on settings dialog
Image Shared in Adobe Cloud : https://acrobat.adobe.com/link/track?ur ... 14702b9520
In the settings dialog user can enter login credentials for a remote repository to fetch files and customize it.
On pressing ok, the connection should be validated & connected and files fetched else and error pop up shown

Image Shared in Adobe Cloud : https://acrobat.adobe.com/link/track?ur ... 62da6ce8aa

This is a sample User flow which we want to automate.

Regards
Tarini
adrian_sorop
Posts: 73
Joined: Wed Jun 22, 2016 2:48 pm

Re: How to write Automated UI test i.e E2E test for custom plugin for oxygen XML editor

Post by adrian_sorop »

Let's assume your OptionspageExtension is something like:

Code: Select all

/**
 * Oxygen page extension for addon.
 * 
 * @author adrian_sorop
 */
public class OptionsPageExtension extends OptionPagePluginExtension  {
  /**
   * Key for option page
   */
  public static final String OPTIONS_PAGE_EXTENSION_KEY = "My_Options_Page_Extension_Key";
  
  /**
   * The component
   */
  private OptionsPageComponent optionsPageComponent = OptionsPageComponent.getInstance();
  
  /**
   * This method is called when "Apply" or "OK" button are pressed in Oxygen preferences page
   * associated with the current plugin.
   */
  @Override
  public void apply(PluginWorkspace pluginWorkspace) {
    optionsPageComponent.doOk();
  }

  /**
   * This method is called when "Restore defaults" button is pressed from the Oxygen option page.
   */
  @Override
  public void restoreDefaults() {
    optionsPageComponent.restoreDefaultOptions();
  }

  /**
   * Page title.
   */
  @Override
  public String getTitle() {
    return "The title";
  }

  /**
   * Initializes the GUI for the option page and loads the stored option values.
   */
  @Override
  public JComponent init(PluginWorkspace pluginWorkspace) {
    return optionsPageComponent;
  }
  /**
   * Page key
   */
  @Override
  public String getKey() {
    return OPTIONS_PAGE_EXTENSION_KEY;
  }
  
  /**
   * The options that will be saved inside the project file when this page is switched to project level
   * inside the preferences dialog.
   * 
   * @return The options presented in this page.
   * 
   * @since 24.0 
   */
  public String[] getProjectLevelOptionKeys() {
    return null;
  }
}
Starting from the documentation example, you can do a simple test:

Code: Select all

public class MyFlowTest extends PluginWorkspaceTCBase  {
  
  /**
   * Constructor.
   */
  public MyFlowTest() throws Exception {
    super(null, 
        new File("frameworks"), 
        new File("plugins"), 
        null, 
        "your_license_here", 
        PluginWorkspaceTCBase.XML_AUTHOR_PRODUCT);
  }
  

  public void testPrefernecesPageIsShown() throws Exception {
  // call this API to opent the Oxygen Prefernces page to a custom Page
    PluginWorkspaceProvider.getPluginWorkspace().showPreferencesPages(
        new String[]{OptionsPageExtension.OPTIONS_PAGE_EXTENSION_KEY}, 
        OptionsPageExtension.OPTIONS_PAGE_EXTENSION_KEY, 
        true);
    flushAWT();
    
    
    assertTrue(OptionsPageComponent.getInstance().isVisible());
  }
}
Unfortunately, there not much I can do here. I can come up with some examples, but I don't know if they apply to you code...
The developers of the plugin can help you.

Later edit: the PluginWorkspaceProvider.getPluginWorkspace().showPreferencesPages() it's a blocking action and should be performed on a javax.swing.SwingUtilities.invokeLater(Runnable)

Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
tarinisunil
Posts: 9
Joined: Thu Mar 04, 2021 9:19 am

Re: How to write Automated UI test i.e E2E test for custom plugin for oxygen XML editor

Post by tarinisunil »

thanks Adrian, let me try it out.
Post Reply