package ru.sfwt.mt.addressbook.appmanager;


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

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(String locator, String text) {
    click(By.name(locator));
    if (text != null) {
      wd.findElement(By.name(locator)).clear();
      wd.findElement(By.name(locator)).sendKeys(text);
    }
  }

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

@@ -503,24 +503,151 @@
  != null) %7B%0A
+      String existingText = wd.findElement(By.name(locator)).getAttribute(%22value%22);%0A      if (! text.equals(existingText)) %7B%0A  
       wd.fin
@@ -678,24 +678,26 @@
 )).clear();%0A
+  
       wd.fin
@@ -739,16 +739,24 @@
 (text);%0A
+      %7D%0A
     %7D%0A  

Add check to exixting text in HelperBase for GroupModificationTests&AddressModificationTests