# Export and import Virtuoso goals

You can export a goal and all its related entities (e.g., journeys, extensions used, environment variables, test data, etc.) as a single JSON file. This can be useful to create a backup or copying specific journeys of a goal to another goal or project.

# Exporting a goal

You can export a goal by clicking on the context menu icon of the goal and then clicking on the Import / Export option.

Export goal - all journeys

Now click on Export button and the browser will download a JSON file containing the exported goal's data.

# Exporting specific journeys

When you want to export only a few journeys, you can disable Export all journeys and select the journeys that should be exported in the list:

Export goal - some journeys

# Importing as a new goal

You can import a goal by clicking on the context menu icon of the project dashboard goals list and then clicking on the Import goal option.

Import goal

Now upload a goal JSON backup file either by drag & drop or by clicking on browse .json file, and once uploaded click on Import.

Import file restriction

The size of the import goal file cannot exceed 8MB.

# Importing specific journeys

By default, all journeys included in the backup JSON file are imported, but you can import specific journeys by disabling Import all journeys and then selecting the journeys that you are interested in:

Import goal - some journeys

# Importing over an existing goal

You can import over an existing goal while controlling how conflicts are resolved. To do this, click on the context menu icon of the goal that you want to import over, and then click on the Import / Export option.

After selecting the file to import, you can choose the approach which Virtuoso should take when resolving conflicts with the dropdown below the filename, and select specific journeys by disabling Import all journeys:

Import over existing goal

The approaches available are:

  • Import and remove any existing journeys will effectively replace all the journeys of your goal;
    • E.g., existing goal has journeys A and B and you import C, the goal will remove A and B and will add C.
  • Import new journeys and keep existing will only import journeys that do not exist on the existing goal but will keep the ones that already belong to the existing goal;
    • E.g., existing goal has A and B and you import A and C, the goal will keep A and B and will add C.
  • Import new journeys and overwrite existing will import journeys that do not exist on the existing goal, replace those that exist on the existing goal with the ones that you are importing in case of conflict and will keep the ones that already belong to the existing goal but do not exist on the backup JSON file;
    • E.g., existing goal has A and B and you import A and C, the goal will replace A, will keep B and will add C.

# Prevent duplication when importing library checkpoints

When importing goals containing library checkpoints, name conflicts may occur. Because library checkpoints with the same name have a higher chance to share the same purpose, instead of automatically renaming the ones being imported, Virtuoso allows you to choose how to resolve the conflicts and prevent duplication.

Library checkpoints import conflicts warning

You will be notified only if there are any conflicts. Click on Review versions to open the conflict resolver wizard.

In the import wizard, each library checkpoint will have two options:

  • Library checkpoint currently used in your project: This will reuse your project's existing library checkpoint with the same name.
  • Library checkpoint from the import: This will use the new library checkpoint from the import file, even if one with the same name already exists in your Project. The imported one will be appended with a number to prevent naming conflicts.

You can compare the library checkpoints side-by-side in the wizard to make an informed decision.

Conflict resolver wizard

After selecting the import options, review the changes before finalizing the import.

Conflict resolver confirmation

Finally, if you choose to resolve conflicts using the imported library checkpoints, Virtuoso will inform you about the name changes that were made to prevent conflicts.

Renaming library checkpoints

# Exporting Virtuoso tests in Selenium format

You can export Virtuoso journeys to run in your local environment, maintain separately, or to use for integrating with specialized tools.

Virtuoso only supports exporting to Selenium-based Java tests. If you require to automatically translate Virtuoso to any other tool or technology, you can export your journeys in full as JSON, and build your own conversion layer to your desired technology. Furthermore, if you need to analyse the tests or their results outside Virtuoso see the public Apps that you can install in your organization.

# Export journeys in Selenium

Virtuoso can export your goals' journeys as Selenium JUnit tests. For this, Virtuoso creates a single Java class file per goal, where each journey is a separate test method.

Open the goal's context menu clicking on the icon and now click on the option Export to Selenium option. The browser will prompt to download the generated Java class file similar to the following example:

// import statements

public class TestClassName_BasedOn_Your_GoalName_And_TimeOfExport {
  private static WebDriver driver;

  @Before
  public void setup() {...}

  @After
  public void cleanup (){...}

  private WebElement getElement(boolean failIfNotPresent, By... selectors) {...}

  /*Journey name*/
  @Test
  public void test_315785() throws Throwable {
    /*Checkpoint: Navigate to My Project's Dashboard*/
      driver.get("https://goal-start-point.url.com/");
      getElement(true,
        By.xpath("/html/body/div/div[1]/div[2]/div/form[1]/div[1]/input"),
        By.cssSelector(":nth-child(1) > .login__input"),
        By.linkText("user email")
      ).sendKeys("[email protected]");
      getElement(true,
        By.xpath("/html/body/div/div[1]/div[2]/div/form[1]/div[2]/input"),
        By.xpath("//*[@id='app']/div[1]/div[2]/div/form[1]/div[2]/input"),
        By.cssSelector(":nth-child(2) > :nth-child(2) > .login__input"),
        By.linkText("password")
      ).sendKeys("some-password");
      getElement(true,
        By.xpath("/html/body/div/div[1]/div[2]/div/form[1]/button"),
        By.xpath("//*[@id='app']/div[1]/div[2]/div/form[1]/button"),
        By.cssSelector(":nth-child(2) > .button"),
        By.linkText("Login")
      ).click();
      TimeUnit.MILLISECONDS.sleep(2000);
  }
}

This test consists of a few parts:

  1. Setup/tear down methods - used to initialize the Selenium web browser and clean up after test execution;
  2. getElement method - a helper method to aid in element selection using Virtuoso's selectors;
  3. Tests for a goal - each test will be written in a Selenium-executable format.

Selenium tests will export the following from Virtuoso:

  • Virtuoso test steps as Selenium instructions;
    • Note: Commands that cannot be exported will generate the comment command not exportable at the appropriate line
  • All current element selectors (excluding intelligent selectors);
  • Journey and checkpoint names as comments.

It is important to note that the tests exported from Export to Selenium do not contain the full functionality of Virtuoso. For example, some of the following will not be possible:

  • Intelligent element selection using hints;

  • Intelligent element healing;

  • Screenshots are not captured by default (although you can add your own screenshot-capturing logic to the Java tests);

  • Popup auto-dismiss;

  • Data driven testing;

  • any other intelligent behaviour from Virtuoso bots.

# Running Selenium tests

Please note that we offer these resources to run exported Selenium tests (as well as the exported journey in Selenium format) on an as-is basis, without any guarantees or explicit support for using, updating, or maintaining them, as this falls outside the core of Virtuoso.

There are some prerequisites to running the Selenium tests exported from Virtuoso:

  • JDK or OpenJDK 11;
  • Google Chrome browser;

Once the prerequisites are fulfilled, the environment needs to be initialized. We provide a template project in which you can simply drop the selenium tests and run them.

  1. Download the prepared Selenium runner template and unzip to a desired directory.
  2. Download the exported selenium tests as described above into the src/test/java directory within the location you unzipped the template project (where Test_My_Goal.java exists).
  3. Execute the tests from the project's root directory in the command line with gradlew test.

This will execute the tests on your local environment in a headless Chrome environment.

Last Updated: 10/17/2023, 8:51:53 AM