galen icon indicating copy to clipboard operation
galen copied to clipboard

Galen Spec generator help

Open deepakkp opened this issue 5 years ago • 1 comments

Hi team, please let us know how to generate spec files. we want to include commands in batch file and generate it or any particular spec generator method. please share the proper steps. i have tried below steps.but no luck.

http://galenframework.com/docs/reference-working-in-command-line/#SpecGenerator

deepakkp avatar Dec 03 '19 05:12 deepakkp

I can share examples on Java what we implemented for our project. Galen test run is based on Selenium (Junit)

public static void generatePageDump(WebDriver driver, String pageName, String specPath) {
    try {
      new GalenPageDump(pageName).dumpPage(driver, SPEC_COMMON_PATH + specPath,
          DUMP_PATH);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
public static void generateSpecByPageDump(String specPath) {
  SpecGenerator generator = new SpecGenerator();
  SpecGeneratorOptions specGeneratorOptions = new SpecGeneratorOptions();
  specGeneratorOptions.setUseGalenExtras(true);

  try (InputStream inputStream =
           new FileInputStream(DUMP_PATH + "/page.json");
       OutputStream outputStream =
           new FileOutputStream(SPEC_COMMON_PATH + specPath, true)) {

    PageSpecGenerationResult pageSpecGenerationResult = generator.generate(inputStream, specGeneratorOptions);
    String spec = generator.generatePageSpec(pageSpecGenerationResult, specGeneratorOptions);

    outputStream.write(spec.getBytes());

  } catch (IOException e) {
    e.printStackTrace();
  }
}

javdeeva avatar Aug 13 '20 17:08 javdeeva