package ru.stqa.pft.addressbook.appmanager;

import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

/**
 * Created by gis on 06.11.2016.
 */
public class HelperBase {
    protected WebDriver wd;

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

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

    protected void type(By locator, String text) {
        click(locator);
        wd.findElement(locator).clear();
        wd.findElement(locator).sendKeys(text);
    }

    public boolean isAlertPresent(FirefoxDriver wd) {
        try {
            wd.switchTo().alert();
            return true;
        } catch (NoAlertPresentException e) {
            return false;
        }
    }

    protected void find(By locator) {
        wd.findElement(locator);
    }
}

@@ -159,16 +159,55 @@
 Driver;%0A
+import org.openqa.selenium.WebElement;%0A
 import o
@@ -562,31 +562,28 @@
     
-click(locator);%0A       
+WebElement element =
  wd.
@@ -602,16 +602,33 @@
 locator)
+;%0A        element
 .clear()
@@ -637,39 +637,23 @@
         
-wd.findElement(locator)
+element
 .sendKey

refactor type() method