Class WebBrowserScript

  • All Implemented Interfaces:
    DataDictionary

    public abstract class WebBrowserScript
    extends VirtualUserScript
    Represents a Web Java Virtual User Script. When a test containing Web Java Virtual Users is run, a WebBrowserVirtualUser object is created by the eggPlant Performance engine for every Virtual User in the test. These WebBrowserVirtualUser objects runs scripts/workflows by creating instances of script classes (which are subclasses of this WebBrowserScript class) and calling the script() method on them.

    Whenever a Web Java Virtual User Script is created using eggPlant Performance Studio, either by recording a web trace and generating the script automatically or by creating a blank script, a template is used to fill in the basic structure of the script.

    e.g.

    
     package com.testplant.testing;
     
     public class MyNewWebJavaScript extends com.facilita.fc.web.WebBrowserScript
     {
         public void pre() throws Exception
         {
             super.pre();
             // Put any code that needs to execute at the start of the test here
    
         }
    
         public void script() throws Exception
         {
             // Place your iterated script code here.
    
         }
     }
     
    The name you give your script in eggPlant Performance Studio will be used as the name of the class in the script file, and the class will be a subclass of WebBrowserScript. (If you have customised the Web Java Virtual User type as outlined in the description of the WebBrowserVirtualUser class, then the script class will be a subclass of the VU Script source class, which will be a subclass of WebBrowserScript.)

    In eggPlant Performance Studio you can define a test which includes a Virtual User Group running your Web Java Virtual User Script (or a workflow containing your script). When the test is run in Test Controller, then code written in the script() method will execute. The script() method will be called a number of times, relating to the number of iterations that the VU Group is set to perform. This may be a fixed number per test, or a VU Group can be set to run continuously for a certain period of time.

    See Also:
    WebBrowserVirtualUser
    • Constructor Detail

      • WebBrowserScript

        public WebBrowserScript()
        For internal use only.
    • Method Detail

      • getWebBrowser

        public WebBrowser getWebBrowser()
        Gets the WebBrowser belonging to this Virtual User.
        Returns:
        the WebBrowser belonging to this Virtual User
      • getProtocol

        public Protocol getProtocol​(java.lang.String key,
                                    java.lang.String defaultValue)
                             throws NoSuchValueException,
                                    NotAllowedException,
                                    BadValueException
        Gets a Protocol by looking up a String in this Virtual User's data dictionary.

        e.g.

        
         // Look in the data dictionary for the key "protocol1". If this key doesn't exist, then default to Protocol.HTTP
         Protocol protocol1 = getProtocol("protocol1", "http");
         
        Parameters:
        key - the key to look for in the data dictionary
        defaultValue - the default value to use if the specified key does not exist in this Virtual User's data dictionary
        Returns:
        the Protocol, or a Protocol relating to the defaultValue parameter
        Throws:
        NoSuchValueException - Invalid protocol name
        NotAllowedException - The key could not be found in the data dictionary
        BadValueException - The key could not be found in the data dictionary
      • getSoapService

        public <T> T getSoapService​(java.lang.Class<T> soapServiceInterface,
                                    Url url,
                                    com.testplant.soap.SoapVersion soapVersion)
                             throws NoSuchValueException,
                                    java.lang.NoSuchMethodException,
                                    java.lang.SecurityException,
                                    java.lang.InstantiationException,
                                    java.lang.IllegalAccessException,
                                    java.lang.IllegalArgumentException,
                                    java.lang.reflect.InvocationTargetException
        Throws:
        NoSuchValueException
        java.lang.NoSuchMethodException
        java.lang.SecurityException
        java.lang.InstantiationException
        java.lang.IllegalAccessException
        java.lang.IllegalArgumentException
        java.lang.reflect.InvocationTargetException