Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
How to get Overall Result of Script in OpenScript

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 LastError15:12:32,345 INFO [1] getLastError null15:12:32,414 INFO [1] No Exception15:12:32,440 INFO [1] isIterationPassed passed15: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();}
Answers
-
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());
}
-
Thank you, this has worked! I now check "getLastError().getMessage() " for null - then I guess it was a success.
-
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.
-
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
-
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.
-
Check what is getting printed
info("{{result.code}}");
Thanks,
DeepuM
-
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
-
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...
Thanks,
DeepuM