Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Need tutorials for Jython in SOA test

kamit2733
kamit2733 Posts: 16

Hi all,

Can some one give me guide regarding scripting in Jython in SOA test .
I am new to SOA test and finding it a bit difficult while scripting in Jython . it would be grateful if some one could give me some kind of study material for Jython.

Thanks

Comments

  • OmarR
    OmarR Posts: 233 admin

    Good evening,

    What are you looking to accomplish with Jython scripting? Perhaps we could help you accomplish the same using the SOAtest tools :smile:

    Aside from documentation, I recommend looking over the "jythonbook" posted in the Jython project page: http://www.jython.org/jythonbook/en/1.0/LangSyntax.html

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Jython is a Python interpreter. So, you also can find many resources and tutorials for the Python language around the web. Concerning SOAtest, feel free to post any specific questions you have if you are not sure how to accomplish something. In general, SOAtest tooling is intended to avoid scripting or otherwise having to manually code test cases.

  • Mounika238
    Mounika238 Posts: 6

    Hello,
    I am new to SOA test and trying to develop a test case to get the count of total no of rows in a web table in a browser.i am assuming that only scripting will accommodate this scenario. Can you please suggest is there a way to do this with SOA tool?

  • jakubiak
    jakubiak Posts: 795 admin

    Yes you will need scripting for this. You can use the SOAtest Extensibility API to accomplish what you want to do.
    1. Record a browser test scenario
    2. At the test step where the table appears, add an Extension Tool by choosing to right-click on the test at that step and selecting Add Output... > Browser contents (rendererd HTML) > Extension Tool.
    3. Write a script like the following in the Extension Tool (this script is written in Groovy):

    import com.parasoft.api.*;
    import org.w3c.dom.*;
    import webking.api.browser2.*;
    
    public void countRows(BrowserContentsInput input, ExtensionToolContext context) {
        Document doc = input.getDocument();
        Element table = WebBrowserTableUtil.getTable("id", "accountTable", doc);
        NodeList rows = table.getElementsByTagName("tr");
        if (rows.getLength() != 12) {
            context.report("Incorrect number of table rows: " + rows.getLength());
        }
    }
    

    The key elements of this script are the following:
    1. com.parasoft.api.BrowserContentsInput is how you can get the contents of the page. There are multiple getDocument() methods that allow you to specify which window/frame for which you want to get the contents.
    2. webking.api.browser2.WebBrowserTableUtil has a number of nice utility methods for working with tables.
    3. com.parasoft.api.ExtensionToolContext is used to report an error in SOAtest

    You can find JavaDocs for these classes by going to Help > Help Contents > Parasoft SOAtest Extensibility API.

  • Mounika238
    Mounika238 Posts: 6

    Hi,
    i am able to extract rows count with the above script by customizing with my table values.
    Thanks!!