Skip to Main Content

General Development Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get Overall Result of Script in OpenScript

Martin ZehetmeierJun 15 2020 — edited Aug 23 2020

Hello,

we use OpenScript (Version: 13.3.0.1 Build 262) on Windows 10 and Internet Explorer 11.900

In my very simple test script I launch a browser, open a website and check for a text on the site "test" which is not present and that's why the test fails.

In the finish section I want to get the overall result of my script (which should be failed - as the Reports says too

Overall Result: Failed

Result failed: The text "test" is not found in the HTML content. 

But however I try to log this result it shows me my script has passed

See below for the output of my own info-Logs.

So my question is: How can I access the result of the Overall Result in the Java code and the summary.

Any help is appreciated.

Please see my code and console below.

15:12:32,315 INFO  [1] has LastError

15:12:32,345 INFO  [1] getLastError null

15:12:32,414 INFO  [1] No Exception

15:12:32,440 INFO  [1] isIterationPassed passed

15:12:32,467 INFO  [1] isLastResultPassed passed

public void initialize() throws Exception {

browser.launch();

}

/**

* Add code to be executed each iteration for this virtual user.

*/

public void run() throws Exception {

beginStep("[1] No Title (/spread)", 0);

{

web

.window(17,

"/web:window[@index='0' or @title='Help Spread DuckDuckGo']")

.navigate("https://duckduckgo.com/spread");

{

think(5.733);

web.assertText("test", "test", Source.DisplayContent,

TextPresence.PassIfPresent, MatchOption.Exact);

}

}

endStep();

}

public void finish() throws Exception {

if (hasLastError()) {

  info("has LastError");

  info("getLastError " + String.valueOf(getLastError()));

}

         Exception exception = getIterationResult().getError();

         if(exception == null){

             info("No Exception");

         }

         else{

             info("Exception");

             info(exception.getMessage());

         }

         boolean isIterationPassed = getIterationResult().isPassed();

         if(isIterationPassed){

           info("isIterationPassed passed");

         }

         else{

           info("isIterationPassed not passed");

         }

       

         boolean isLastResultPassed = getLastResult().isPassed();

         if(isLastResultPassed){

           info("isLastResultPassed passed");

         }

         else{

           info("isLastResultPassed not passed");

         }

 

   browser.close();

}

Comments

Deepu Muraleedharan

Hi Martin,

Try getLastError().getMessage()

public void run() throws Exception {

        beginStep("");{

            web.assertText("test", "aaaa", Source.DisplayContent,

                    TextPresence.PassIfPresent, MatchOption.Exact);

           

        }endStep();

    }

    public void finish() throws Exception {

        System.out.println(getLastError().getMessage());

    }

Martin Zehetmeier

Thank you, this has worked! I now check "getLastError().getMessage() " for null - then I guess it was a success.

Martin Zehetmeier

@deepu-muraleedharan
I still have a problem.
In cases of a runtime problem like
oracle.oats.scripting.modules.basic.api.exceptions.VariableNotFoundException
this does not seem to work. As there also "getLastError().getMessage() " is null.

Deepu Muraleedharan

Hi Martin,
Try this.....
public void run() throws Exception {
try{
beginStep("Step 1");{
info("{{testVar}}");
}endStep();
}
catch(Exception e){
System.out.println("Outcome :" + getStepResult().getOutcome());
System.out.println("Outcome :" + getStepResult().getErrorString());
}
}
public void finish() throws Exception {
if(getLastError()!= null)
System.out.println(getLastError().getMessage());
}

Thanks,
DeepuM

Martin Zehetmeier

Hi, thank you again!
Does it make a difference in general when we have an assertion that fails or something unexpectedly happens at runtime like the site does not load (timeout) or an element was not found?
Because when I use "fail" to failk my test or an assertion fails like "assertAttributes" it seems to work getting getLastError().getMessage() but whenever an unexpected thing happens it also Null though I would expect a error message should be there.

I really wonder how the script itself gets the Overall Result and if it's possible to get this easily in the finish-section.

Deepu Muraleedharan

Check what is getting printed
info("{{result.code}}");

Thanks,
DeepuM

Martin Zehetmeier

Hello Deepu,

I tried it:
public void finish() throws Exception {
info("Result.Code: " + "{{result.code}}");
}

I made my test fail by inserting an invalid object which leads to:

oracle.oats.scripting.modules.webdom.common.api.exception.PlaybackException:

INFO [1] Result.Code: PASS

Deepu Muraleedharan

Hi Martin,
I'm using code as follows...
Every stepgroup last line will be a library method call to fetch status, duration, and comments. So we can either store or print in console or database/report. I'm storing all stepgroup results to Map<id, List>, and calling a method in the finish to consolidate and insert to a database for report dashboard. This may help you...

image.pngimage.pngimage.png
Thanks,
DeepuM

1 - 8

Post Details

Added on Jun 15 2020
8 comments
233 views