1 Reply Latest reply: Dec 5, 2012 12:43 PM by glenn.s RSS

    why I can not use API to design my tasks with java code ?

    977818
      Hi all,
      I 'm a new openscript starter, and I try to use openscript testing tool to finish my job
      and I meet a problem is that I can not use java code to encapsulate APIs of openscript as my common tasks

      eg : here is a script.java file

           public void initialize() throws Exception {
           
           }
                
           /**
           * Add code to be executed each iteration for this virtual user.
           */
           public void run() throws Exception {

           }
           
           public void finish() throws Exception {
           }

      I want select browser type and lunch browser as a common task in another java file which name is ConfigBrowser.java and the content is like this

      import oracle.oats.scripting.modules.basic.api.*;
      import oracle.oats.scripting.modules.basic.api.exceptions.AbstractScriptException;
      import oracle.oats.scripting.modules.browser.api.BrowserService;
      import oracle.oats.scripting.modules.browser.api.BrowserSettings.BrowserType;
      import oracle.oats.scripting.modules.browser.api.utilities.exceptions.BrowserException;

      public class ConfigBrowser{
           public static BrowserService browser;
           
           public static void setUp() throws AbstractScriptException
           {
                browser.setBrowserType(BrowserType.Firefox);
                browser.launch();
           }
      }

      after this , I want use this task in the script.java file initialize section
      so the content looks like this :

      public void initialize() throws Exception {
           ConfigBrowser.setup();
           }
                
           /**
           * Add code to be executed each iteration for this virtual user.
           */
           public void run() throws Exception {

           }
           
           public void finish() throws Exception {
           }
      When I try to run script.java I will get NullPointerException error message
      anybody can answer my question that does openscript tool support java ? if yes , how ?
        • 1. Re: why I can not use API to design my tasks with java code ?
          glenn.s
          I do not have OpenScript in front of me right now, so cannot confirm. Most likely it is because you have not instantiated BrowserService as the "browser" variable in your new class. You can step through the code with debugger to find the reasons for these type of failures if you plan to write custom java code in the future.
          // not sure if this is the complete constructor. Check to be sure.
          public static BrowserService browser = new BrowserService();