package com.example.fw;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.Select;

public abstract class HelperBase {

		protected ApplicationManager manager;
		protected WebDriver driver;
		public boolean acceptNextAlert = true;

		public HelperBase(ApplicationManager manager) {
			this.manager = manager;	
			this.driver = manager.driver;
  }
		public boolean isElementPresent(By by) {
		    try {
		      driver.findElement(by);
		      return true;
		    } catch (NoSuchElementException e) {
		      return false;
		    }
		  }

		public String closeAlertAndGetItsText() {
		    try {
		      Alert alert = driver.switchTo().alert();
		      String alertText = alert.getText();
		      if (acceptNextAlert) {
		        alert.accept();
		      } else {
		        alert.dismiss();
		      }
		      return alertText;
		    } finally {
		     acceptNextAlert = true;
		    }
		  }
		protected void type(By locator, String text) {
			if (text != null) {
			driver.findElement(locator).clear();
			driver.findElement(locator).sendKeys(text);
		  }
		}
		protected void click(By locator) {
			driver.findElement(locator).click();
		}
		
		protected void selectByText(By locator, String text) {
			if (text != null) {
			new Select(driver.findElement(locator)).selectByVisibleText(text);
		  }
		}
			
}

@@ -172,16 +172,55 @@
 Driver;%0A
+import org.openqa.selenium.WebElement;%0A
 import o
@@ -1129,24 +1129,52 @@
  null) %7B%0A%09%09%09
+WebElement elementLocator = 
 driver.findE
@@ -1188,16 +1188,35 @@
 locator)
+;%0A%09%09%09elementLocator
 .clear()
@@ -1224,35 +1224,22 @@
 %0A%09%09%09
-driver.findE
+e
 lement
-(l
+L
 ocator
-)
 .sen

add local variable in 'type' method