package com.seleniumtests.webelements;

import com.seleniumtests.core.TestLogging;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriverException;

public class TextFieldElement extends HtmlElement {
	public TextFieldElement(String label, By by) {
		super(label, by);
	}

	public void clear() {
		TestLogging.logWebStep(null, "Remove data From " + toHTML(), false);
		findElement();
		if (!element.getAttribute("type").equalsIgnoreCase("file"))
			element.clear();
	}

	public void sendKeys(String keysToSend) {
		TestLogging.logWebStep(null, "Enter data: \"" + keysToSend + "\" on "
                + toHTML(), false);
		findElement();
		element.sendKeys(keysToSend);
	}

	public void type(String keysToSend) {
		try {
			clear();
		} catch (WebDriverException e) {
			TestLogging.logWebStep(null, "Exception:clear value on " + toHTML(),
                    false);
		}
		sendKeys(keysToSend);
	}

    public void clearAndType(String keysToSend) {
        clear();
        type(keysToSend);
    }
}

@@ -110,55 +110,8 @@
 .By;
-%0Aimport org.openqa.selenium.WebDriverException;
 %0A%0Apu
@@ -676,167 +676,8 @@
 ) %7B%0A
-%09%09try %7B%0A%09%09%09clear();%0A%09%09%7D catch (WebDriverException e) %7B%0A%09%09%09TestLogging.logWebStep(null, %22Exception:clear value on %22 + toHTML(),%0A                    false);%0A%09%09%7D%0A
 %09%09se

remove clear operation from type API