Code Search for Developers
 
 
  

MockHtmlUnitHelper.java from Jameleon at Krugle


Show MockHtmlUnitHelper.java syntax highlighted

/*
    Jameleon HtmlUnit plug-in - A plug-in that uses HtmlUnit to drive web sites
    Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
    
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111AssertLevel.NO_FUNCTION07 USA
*/
package net.sf.jameleon.plugin.htmlunit.util;

import com.gargoylesoftware.htmlunit.html.*;

import java.io.File;
import java.io.IOException;


/**
 * This is a mock class
 */
public class MockHtmlUnitHelper extends HtmlUnitHelper{

    public String clickElementWithXPathXPath;
    public String getHtmlElementByXPathXPath;
    public String getHtmlInputByXPathXPath;
    public String navigateUrl;
    public String setHiddenField;
    public String setHtmlInputValueValue;
    public String setHtmlInputValueType;
    public String setHtmlInputValueByXPathXPath;
    public String setHtmlInputValueByXPathValue;
    public String setHtmlInputValueByXPathType;
    public String storeFileName;
    public String getHtmlElementByAttributeNameAndValueTagname;
    public String getHtmlElementByAttributeNameAndValueAttributeName;
    public String getHtmlElementByAttributeNameAndValueAttributeValue;
    public String getHtmlFormByIdAttributeValue;
    public String getHtmlFormByNameAttributeValue;
    public String getHtmlFormByXPath;
    public String setCheckBoxName;
    public String setCheckBoxValue;
    public String setRadioButtonName;
    public String setRadioButtonValue;
    public String setFileField;
    public String setPasswordField;
    public String setSelectFieldByValueName;
    public String setSelectFieldByValueAttribute;
    public String setSelectFieldByOptionTextName;
    public String setSelectFieldByOptionText;
    public String setSelectFieldByIndexName;
    public String setSelectFieldByXPath;
    public int setSelectFieldByIndex;
    public String setTextField;
    public String setTextArea;
    public int getHtmlFormByIndex;

    public MockHtmlUnitHelper(HtmlUnitDelegate delegate){
        super(delegate);
    }

    public void clickElementWithXPath(String xpath){
        clickElementWithXPathXPath = xpath;
    }

    public HtmlElement getHtmlElementByXPath(String xpath){
        getHtmlElementByXPathXPath = xpath;
        return null;
    }

    public HtmlElement getHtmlElementByAttributeNameAndValue(String tagname, String attributeName, String attributeValue){
        getHtmlElementByAttributeNameAndValueTagname = tagname;
        getHtmlElementByAttributeNameAndValueAttributeName = attributeName;
        getHtmlElementByAttributeNameAndValueAttributeValue = attributeValue;
        return null;
    }

    public HtmlForm getHtmlFormById(String attributeValue){
        getHtmlFormByIdAttributeValue = attributeValue;
        return null;
    }

    public HtmlForm getHtmlFormByIndex(int index){
        getHtmlFormByIndex = index;
        return null;
    }

    public HtmlForm getHtmlFormByName(String attributeValue){
        getHtmlFormByNameAttributeValue = attributeValue;
        return null;
    }

    public HtmlForm getHtmlFormByXPath(String xpath){
        getHtmlFormByXPath = xpath;
        return null;
    }

    public void setCheckBox(String fieldName, boolean checked){
        setCheckBoxName = fieldName;
    }

    public void setCheckBox(String fieldName, String fieldValue, boolean checked){
        setCheckBoxName = fieldName;
        setCheckBoxValue = fieldValue;
    }

    public void setFileField(String fieldName, String value){
        setFileField = fieldName;
    }

    public void setHiddenField(String fieldName, String value){
        setHiddenField = fieldName;
    }

    public void setPasswordField(String fieldName, String value){
        setPasswordField = fieldName;
    }

    public void setRadioButton(String fieldName, String fieldValue, boolean checked){
        setRadioButtonName = fieldName;
        setRadioButtonValue = fieldValue;
    }

    public void setSelectFieldByIndex(String fieldName, int index, boolean selected){
        setSelectFieldByIndexName = fieldName;
        setSelectFieldByIndex = index;
    }

    public void setSelectFieldByOptionText(String fieldName, String optionText, boolean selected){
        setSelectFieldByOptionTextName = fieldName;
        setSelectFieldByOptionText = optionText;
    }

    public void setSelectFieldByValue(String fieldName, String value, boolean selected){
        setSelectFieldByValueName = fieldName;
        setSelectFieldByValueAttribute = value;
    }

    public void setSelectFieldByXPath(String xpath, boolean selected){
        setSelectFieldByXPath = xpath;
    }

    public void setTextArea(String fieldName, String value){
        setTextArea = fieldName;
    }

    public void setTextField(String fieldName, String value){
        setTextField = fieldName;
    }

    public void setHtmlInputValue(HtmlInput input, String value, String type){
        setHtmlInputValueValue = value;
        setHtmlInputValueType = type;
    }

    public void setHtmlInputValueByXPath(String xpath, String value, String type){
        setHtmlInputValueByXPathXPath = xpath;
        setHtmlInputValueByXPathValue = value;
        setHtmlInputValueByXPathType = type;
    }

    public File store(String fName) throws IOException{
        storeFileName = fName;
        return null;
    }

    public void navigate(String url){
        navigateUrl = url;
    }
}




See more files for this project here

Jameleon

Jameleon is a data-driven automated testing tool that is easily extensible via plug-ins. Features of applications are automated in Java and tied together independently in XML, creating self-documenting automated test cases.

Project homepage: http://sourceforge.net/projects/jameleon
Programming language(s): Java,XML
License: other

  HtmlUnitHelperTest.java
  MockHtmlUnitHelper.java