package ru.stqa.pft.addressbook.appmanager;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class HelperBase {
    protected WebDriver browser;

    public HelperBase(WebDriver browser) {
        this.browser = browser;
    }

    protected void type(By locator, String text) {
        if (text != null) {
            click(locator);
            clear(locator);
            send(locator, text);
        }
    }

    private void send(By locator, String text) {
        if (text != null)
            browser.findElement(locator).sendKeys(text);
    }

    private void clear(By locator) {
        browser.findElement(locator).clear();
    }

    protected void click(By locator) {
        browser.findElement(locator).click();
    }

    protected void selectValueFromSelector(WebElement selectLocator, String value) {
        Select select = new Select(selectLocator);
        select.selectByValue(value);
    }
}

@@ -460,24 +460,160 @@
  != null) %7B%0A
+            String existingText = browser.findElement(locator).getAttribute(%22value%22);%0A            if (!text.equals(existingText)) %7B%0A    
             
@@ -640,16 +640,20 @@
         
+   
+ 
 clear(lo
@@ -652,32 +652,36 @@
 clear(locator);%0A
+    
             send
@@ -693,24 +693,38 @@
 tor, text);%0A
+            %7D%0A
         %7D%0A  

optimise type method