Package jp.vmi.selenium.selenese

Source Code of jp.vmi.selenium.selenese.SeleneseRunnerMutator

package jp.vmi.selenium.selenese;

import com.thoughtworks.selenium.webdriven.CompoundMutator;
import com.thoughtworks.selenium.webdriven.ScriptMutator;
import com.thoughtworks.selenium.webdriven.VariableDeclaration;

import jp.vmi.selenium.selenese.VariableDeclarationWithDynamicValue.DynamicValue;

/**
* Substitute for CompoundMutator without static base URL.
*/
public class SeleneseRunnerMutator extends CompoundMutator implements ScriptMutator {

    private static final String BASE_URL = "selenium.browserbot.baseUrl";

    private final Context context;

    /**
     * Constructor.
     *
     * @param context Selenese Runner context.
     */
    public SeleneseRunnerMutator(Context context) {
        super("");
        this.context = context;
    }

    @Override
    public void addMutator(ScriptMutator mutator) {
        if (mutator instanceof VariableDeclaration) {
            StringBuilder mutated = new StringBuilder();
            mutator.mutate(BASE_URL, mutated);
            if (mutated.length() > 0) {
                mutator = new VariableDeclarationWithDynamicValue(BASE_URL, new DynamicValue() {
                    @Override
                    public String getValue() {
                        return context.getCurrentBaseURL();
                    }
                });
            }
        }
        super.addMutator(mutator);
    }
}
TOP

Related Classes of jp.vmi.selenium.selenese.SeleneseRunnerMutator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.