Skip to content

Faker Actions related to Commerce

productName

Description: This function will generate a random product name

Input Format : DatasheetName:ColumnName

ObjectName Action Input Condition Reference
Synthetic Data 🟢 productName DatasheetName:ColumnName ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate a random product name", input = InputType.YES, condition = InputType.NO)
    public void productName() {
        try {
            String strObj = Input;
            String productName = faker.get(key).commerce().productName();
            Report.updateTestLog(Action, "Generated data: " + productName, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, productName);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }

commerceDepartment

Description: This function will generate a random commerce department name

Input Format : DatasheetName:ColumnName

ObjectName Action Input Condition Reference
Synthetic Data 🟢 commerceDepartment DatasheetName:ColumnName ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate a random commerce department name", input = InputType.YES, condition = InputType.NO)
    public void commerceDepartment() {
        try {
            String strObj = Input;
            String department = faker.get(key).commerce().department();
            Report.updateTestLog(Action, "Generated data: " + department, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, department);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }

commercePrice

Description: This function will generate a random commerce price

Input Format : DatasheetName:ColumnName

ObjectName Action Input Condition Reference
Synthetic Data 🟢 commercePrice DatasheetName:ColumnName ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate a random price", input = InputType.YES, condition = InputType.NO)
    public void commercePrice() {
        try {
            String strObj = Input;
            String price = faker.get(key).commerce().price();
            Report.updateTestLog(Action, "Generated data: " + price, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, price);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }

priceWithinRange

Description: This function will generate a random price within a range

Input Format : DatasheetName:ColumnName

Condition Format: minimum and maximum range, for example: 45:1005.99

ObjectName Action Input Condition Reference
Synthetic Data 🟢 priceWithinRange DatasheetName:ColumnName minimum and maximum range ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate price within a range", input = InputType.YES, condition = InputType.YES)
    public void priceWithinRange() {
        try {
            String strObj = Input;
            String inputMin = Condition.split(":", 2)[0];
            String inputMax = Condition.split(":", 2)[1];
            Double min = Double.parseDouble(inputMin);
            Double max = Double.parseDouble(inputMax);
            String price = faker.get(key).commerce().price(min, max);
            Report.updateTestLog(Action, "Generated data: " + price, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, price);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }

commerceMaterial

Description: This function will generate a random material name

Input Format : DatasheetName:ColumnName

ObjectName Action Input Condition Reference
Synthetic Data 🟢 commerceMaterial DatasheetName:ColumnName ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate a random material name", input = InputType.YES, condition = InputType.NO)
    public void commerceMaterial() {
        try {
            String strObj = Input;
            String material = faker.get(key).commerce().material();
            Report.updateTestLog(Action, "Generated data: " + material, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, material);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }

commerceColor

Description: This function will generate a random color name

Input Format : DatasheetName:ColumnName

ObjectName Action Input Condition Reference
Synthetic Data 🟢 commerceColor DatasheetName:ColumnName ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate a random color name", input = InputType.YES, condition = InputType.NO)
    public void commerceColor() {
        try {
            String strObj = Input;
            String color = faker.get(key).commerce().color();
            Report.updateTestLog(Action, "Generated data: " + color, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, color);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }

promotionCode

Description: This function will generate a random promotion Code

Input Format : DatasheetName:ColumnName

ObjectName Action Input Condition Reference
Synthetic Data 🟢 promotionCode DatasheetName:ColumnName ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate a random promotion code", input = InputType.YES, condition = InputType.NO)
    public void promotionCode() {
        try {
            String strObj = Input;
            String promotionCode = faker.get(key).commerce().promotionCode();
            Report.updateTestLog(Action, "Generated data: " + promotionCode, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, promotionCode);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }

promotionCodeWithDigits

Description: This function will generate a random promotion Code

Input Format : DatasheetName:ColumnName

Condition Format: number of digits, for example: 14

ObjectName Action Input Condition Reference
Synthetic Data 🟢 promotionCodeWithDigits DatasheetName:ColumnName number of digits ⬅ Store in Datasheet
@Action(object = ObjectType.FAKER, desc = "Generate a random promotion code with digits", input = InputType.YES, condition = InputType.YES)
    public void promotionCodeWithDigits() {
        try {
            String strObj = Input;
            String digitStr= Condition;
            Integer digits = Integer.parseInt(digitStr);
            String promotionCode = faker.get(key).commerce().promotionCode(digits);
            Report.updateTestLog(Action, "Generated data: " + promotionCode, Status.DONE);
            String sheetName = strObj.split(":", 2)[0];
            String columnName = strObj.split(":", 2)[1];
            userData.putData(sheetName, columnName, promotionCode);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during data generation", ex);
            Report.updateTestLog(Action, "Error generating data: " + "\n" + ex.getMessage(), Status.DEBUG);
        }
    }