package framework.controls;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import framework.controls.interfaces.Clickable;
import framework.controls.interfaces.Readable;

/**
 * This class comprises of functionality that would be used 
 * when interacting with a typical button control.
 * @author nvonop
 *
 */
public class Button extends BaseControl implements Clickable, Readable {

	/**
	 * Constructor that takes a WebDriver object and By object.  
	 * These are then set in the base class.
	 * @param driver
	 * @param locator
	 */
	public Button(WebDriver driver, By locator) {
		setDriver(driver);
		setLocator(locator);
	}

	/* (non-Javadoc)
	 * @see framework.controls.interfaces.Readable#read()
	 */
	@Override
	public Object read() {
		return getUnderlyingWebElement().getText();
	}

	/* (non-Javadoc)
	 * @see framework.controls.interfaces.Clickable#click()
	 */
	@Override
	public void click() {
		try {
			getUnderlyingWebElement().click();
		} catch (WebDriverException e) {
			if (e.getMessage().contains("Element is not clickable at point")) {
				click();
			}
			e.printStackTrace();
		}
	}

}

@@ -931,17 +931,8 @@
 ) %7B%0A
-%09%09try %7B%0A%09
 %09%09ge
@@ -968,160 +968,8 @@
 ();%0A
-%09%09%7D catch (WebDriverException e) %7B%0A%09%09%09if (e.getMessage().contains(%22Element is not clickable at point%22)) %7B%0A%09%09%09%09click();%0A%09%09%09%7D%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A
 %09%7D%0A%0A

Update Button.java