Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Oct 05, 2020 12:52

This article explains how you can pass dynamic data from a .csv file to Quantum.

To pass dynamic data:

  1. Create a .csv file containing the data you want to pass to Quantum. The following example shows a .csv file source that contains two pairs of contact names with contact phones.

    Perfecto Quantum,1234
    Quantum Perfecto,4567
  2. Place the file in the following folder: src/main/resources/data/
  3. Create a feature file that takes the .csv columns as input and points to the data file, as shown in the following example.

    Feature: Add Contact
      Scenario Outline: Dynamic Data
        Given I launch Contacts application
        Then I Add Contact with name "<contactName>" and number  "<phoneNumber>"
      Examples: {'datafile' : 'src/main/resources/data/contactNames.csv'}
  4. Add an implementation for the step that uses the .csv data, as shown in the following example.

        @When("I Add Contact with name \"([^\"]*)\" and number  \"([^\"]*)\"$")
        public void I_add_contact_with_name(String contactName, String phoneNumber) throws Throwable {
            if (!isAndroid()) {
                System.out.println("this is an iOS");
            //Add contact
            // in some Android devices, after clicking on add contact, a popup appears asking which account to save the contact under
            //we will look for this and if it appears select the device option
            if (isAndroid()) {
                if(isText("Save contacts to",20)) {
            DeviceUtils.waitForPresentTextVisual("Phone", 20);
            //Insert name and number
            DeviceUtils.waitForPresentTextVisual(phoneNumber, 20);
            //Save contact
            if (isAndroid()) {
                DeviceUtils.waitForPresentTextVisual("connected via", 20);
                //return to main screen
                DeviceUtils.waitForPresentTextVisual("contacts groups more", 20);
  5. Run the test by adding the scenario's tag to your TestNG.xml configuration file.