package org.getopentest.selenium;

import org.getopentest.selenium.core.SeleniumTestAction;
import org.openqa.selenium.Keys;

public class ActionsSendKeys extends SeleniumTestAction {

    @Override
    public void run() {
        super.run();

        String text = this.readStringArgument("text", null);
        String key = this.readStringArgument("key", null);

        if (text != null) {
            SeleniumTestAction.getActionsInstance().sendKeys(text);
        } else if (key != null) {
            SeleniumTestAction.getActionsInstance().sendKeys(Keys.valueOf(key.toUpperCase()));
        } else {
            throw new RuntimeException("Neither the \"text\" argument, nor the \"key\" argument were provided.");
        }
    }
}
