Skip to content

Tutorial: Create new test application

iks github user edited this page May 28, 2019 · 36 revisions
  1. Create file ./sysnat.test.runtime.environment/src/main/resources/execution_properties/GoogleSearch.properties.

  2. Give the new properties file the following content:

    isWebApplication=true 
    withLogin=false 
    StartParameter=starturl          
    
    googlesearch.production.starturl=https://www.google.com/ 
    
  3. Create java class ./sysnat.test.runtime.environment/src/main/java/com/iksgmbh/sysnat/language_templates/homepageiks/LanguageTemplatesGoogleSearch.java.

  4. Give the new java file the following content:

    package com.iksgmbh.sysnat.language_templates.googlesearch;
    
    import static com.iksgmbh.sysnat.common.utils.SysNatConstants.QUESTION_IDENTIFIER;
    
    import java.io.File;
    import java.util.HashMap;
    import java.util.List;
    
    import com.iksgmbh.sysnat.ExecutionRuntimeInfo;
    import com.iksgmbh.sysnat.ExecutableExample;
    import com.iksgmbh.sysnat.annotation.LanguageTemplate;
    import com.iksgmbh.sysnat.annotation.LanguageTemplateContainer;
    import com.iksgmbh.sysnat.common.utils.SysNatFileUtil;
    import com.iksgmbh.sysnat.common.utils.SysNatConstants.WebLoginParameter;
    import com.iksgmbh.sysnat.language_templates.LanguageTemplates;
            
    /** 
     * Contains the basic language templates for applicable 
     * for the Google Search test application. 
     */ 
     @LanguageTemplateContainer 
     public class LanguageTemplatesGoogleSearch implements LanguageTemplates 
     { 
          private ExecutableExample executableExample; 
          private ExecutionRuntimeInfo executionInfo; 
            
          public LanguageTemplatesGoogleSearch(ExecutableExample aExecutableExample) 
          {
              this.executableExample = aExecutableExample;
              this.executionInfo = ExecutionRuntimeInfo.getInstance();
          }
            
          //#############################################################################
          //                     I N T E R F A C E    M E T H O D S
          //#############################################################################
            
          @Override
          public void doLogin(final HashMap<WebLoginParameter,String> startParameter) {
              // no login/logout for Ithis test application
          }
    
          @Override
          public void doLogout() {
              // no login/logout for this test application
          }
    
          @Override
          public boolean isLoginPageVisible() {
              return false; // no login for this test application
          }
    
          @Override
          public boolean isStartPageVisible() {
              try {
                  return executableExample.isTextCurrentlyDisplayed("Über Google");
               } catch (Exception e) {
                   return false;
               }
          }
    
          @Override
          public void gotoStartPage() {
              if ( ! isStartPageVisible() ) {
                  getGuiController().reloadCurrentPage();
              }
          }
            
          //##########################################################################################
          //                   L A N G U A G E   T E M P L A T E    M E T H O D S
          //##########################################################################################
            
          // TODO: add methods that represent natural language instructions
    }
    
  5. Open file ./sysnat.natural.language.executable.examples/settings.config.

  6. Line 4 contains the comma separated list of available test applications. Add GoogleSearch to this list.

  7. Start SysNat with SystemConfigDialog, select the new test application and start test execution.

  8. Check the test report. No problems should be mentioned, but no executable example has been found.

Clone this wiki locally