⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webform.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* Description: get the list of file parameters that will be added to the    *//*              request.                                                     *//* Parameters: none                                                          *//* Returns: list of file parameters that will be added to the request        *//*                                                                           *//*****************************************************************************/            public Vector getActiveFiles()    {        Vector list = new Vector();        int j;        for (int i = 0; i < params.length; i++)        {            if (params[i].getType().equals("input type=file"))            {                Vector[] subList = params[i].paramString();                                for (j = 0; j < subList.length; j++)                    list.addElement(subList[j]);            }        }        if (list.size() == 0)            return null;                return list;    }    /*****************************************************************************//*                                                                           *//* Method: getAllParameters                                                  *//* Description: get the list of parameters that are part of this form.       *//* Parameters: none                                                          *//* Returns: list of parameters associated with this form                     *//*                                                                           *//*****************************************************************************/        public Parameter[] getAllParameters()    {        return params;    }    /*****************************************************************************//*                                                                           *//* Method: reset                                                             *//* Description: reset this form to its initial values.  This does not change *//*              the currently selected submit option.                        *//* Parameters: none                                                          *//* Returns: void                                                             *//*                                                                           *//*****************************************************************************/        public void reset()    {        // this does not reset the values of all control elements        the_form.reset();                // reset all parameters        for (int i = 0; i < params.length; i++)            params[i].reset();    }    /*****************************************************************************//*                                                                           *//* Method: findParameter                                                     *//* Description: get the index of the parameter with a key of key             *//*              -1 indicates the name is not in a list                       *//* Parameters: key - identifier key being searched for                       *//* Returns: index of the parameter with a key of key -1 if the key is not in *//*          the parameter list                                               *//*                                                                           *//*****************************************************************************/        int findParameter(String key)    {        for (int i = 0; i < params.length; i++)        {            if (params[i].getKey() == null)            {                if (key.equals("null"))                    return i;            }            else if (params[i].getKey().equals(key))            {                return i;            }        }                        return -1;    }    /*****************************************************************************//*                                                                           *//* Method: getParameterSummary                                               *//* Description: get the summary of the specified parameter                   *//* Parameters: key - the identifier key of the parameter                     *//* Returns: a summary of the specified parameter                             *//*                                                                           *//*****************************************************************************/            public HashMap getParameterSummary (String key)                                      throws InvalidElementIDException    {        int indx = findParameter(key);            if (indx == -1)        {            throw new InvalidElementIDException (key, "Control " + key);        }                return params[indx].getSummary();    }        /*****************************************************************************//*                                                                           *//* Method: getParameterValue                                                 *//* Description: get the value of the specified parameter                     *//* Parameters: key - the identifier key of the parameter                     *//* Returns: the value of the specified parameter                             *//*                                                                           *//*****************************************************************************/            public String getParameterValue (String key)                                      throws InvalidElementIDException    {        int indx = findParameter(key);            if (indx == -1)            throw new InvalidElementIDException (key, "Control " + key);                return params[indx].getValue();    }    /*****************************************************************************//*                                                                           *//* Method: setParameterValue                                                 *//* Description: set the value of the specified parameter                     *//* Parameters: key - the identifier key of the parameter                     *//*             value - the new value of the parameter                        *//* Returns: void                                                             *//*                                                                           *//*****************************************************************************/            public void setParameterValue (String key, String value)                                    throws InvalidElementIDException,                                            InvalidParameterValueException    {        int indx = findParameter(key);            if (indx == -1)        {            System.out.println("Couldn't find key " + key);            throw new InvalidElementIDException (key, "Control " + key);        }                params[indx].setValue(value);    }    /*****************************************************************************//*                                                                           *//* Method: getParameterKeyList                                               *//* Description: get a list of keys for all the parameters                    *//* Parameters: none                                                          *//* Returns: a list of keys for the parameters                                *//*                                                                           *//*****************************************************************************/        public String[] getParameterKeyList()    {        String[] list = new String[params.length];                for (int i = 0; i < params.length; i++)            list[i] = params[i].getKey();                    return list;    }            /*****************************************************************************//*                                                                           *//* Method: getHeaders                                                        *//* Description: get the list of headers that will be added to the request.   *//* Parameters: none                                                          *//* Returns: list of headers that will be added to the request                *//*                                                                           *//*****************************************************************************/            public HashMap getHeaders()    {        HashMap map = new HashMap();            /*        // XXX Are these correct ?         if (! the_form.hasAttribute("enctype"))            map.put("Content-Type", the_form.getEnctype());                        if (! the_form.hasAttribute("accept-charset"))            map.put("Accept-Charset", the_form.getAcceptCharset());                    if (! the_form.hasAttribute("accept"))            map.put("Accept", the_form.getAttribute("accept"));                if (! the_form.hasAttribute("lang"))            map.put("Content-Language", the_form.getAttribute("lang"));    */        if (map.isEmpty())            return null;                            return map;    }    /*****************************************************************************//*                                                                           *//* Method: getSummary                                                        *//* Description: get a summary of the form.                                   *//* Parameters: none                                                          *//* Returns: description of a form                                            *//*                                                                           *//*****************************************************************************/        public HashMap getSummary()    {        HashMap summary = new HashMap();                summary.put(WebElement.NAME, name);        summary.put(WebElement.ID, id);                summary.put(WebElement.INDEX, new Integer(index));        summary.put(WebSession.REQUEST_METHOD, getMethod());        summary.put(WebSession.REQUEST_URL, getAction());        summary.put(WebSession.REQUEST_HEADERS, getHeaders());        summary.put(CONTROLS, Arrays.asList(getAllParameters()));                        return summary;    }    } // end class WebForm

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -