# 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 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.

# Importing specific journeys

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

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 hat 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.

# 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.

We currently support Selenium as an export format, with other export formats available on demand (please contact our support if this becomes a need).

# 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 journeys in 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 Journeys in 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

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

  • JDK 8+;
  • Google Chrome browser;
  • Chrome driver: http://chromedriver.chromium.org/downloads

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 test by running gradlew test in the command line, from the project's root directory.
    • The latest version of Chrome web driver should be automatically downloaded.

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

Last Updated: 10/19/2021, 7:39:27 AM