# 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 Import / Export
option.
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:
# Importing as a new goal
You can import a goal by clicking on the context menu icon Import goal
option.
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:
# 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 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
:
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
andB
and you importC
, the goal will removeA
andB
and will addC
.
- E.g., existing goal has journeys
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
andB
and you importA
andC
, the goal will keepA
andB
and will addC
.
- E.g., existing goal has
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
andB
and you importA
andC
, the goal will replaceA
, will keepB
and will addC
.
- E.g., existing goal has
Importing journeys with library checkpoints
Any library checkpoints included in the journeys will be created as new ones, preserving the source ones untouched.
If the target project already contains a library checkpoint with the same name as the imported one, the newly created library checkpoint will be renamed by appending an ordinal number.
# 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 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:
- Setup/tear down methods - used to initialize the Selenium web browser and clean up after test execution;
getElement
method - a helper method to aid in element selection using Virtuoso's selectors;- 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
- Note: Commands that cannot be exported will generate the comment
- 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
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.
- Download the prepared Selenium runner template and unzip to a desired directory.
- Download the exported selenium tests as described above into the
src/test/java
directory within the location you unzipped the template project (whereTest_My_Goal.java
exists). - 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.