<commit_before>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 Administrator on 28.01.2017.
 */
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 );
    if (text != null) {
      wd.findElement ( locator ).clear ();
      wd.findElement ( locator ).sendKeys ( text );

    }

  }

  public boolean isAlertPresent() {
    try {
      wd.switchTo ().alert ();
      return true;
    } catch (NoAlertPresentException e) {
      return false;
    }
  }
}<commit_msg>Оптимизация ввода в уже заполненные поля<commit_after>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 Administrator on 28.01.2017.
 */
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 );
    if (text != null) {
      String existingText = wd.findElement ( locator ).getAttribute ( "value" );
      if (! text.equals ( existingText )) {
        wd.findElement ( locator ).clear ();
        wd.findElement ( locator ).sendKeys ( text );
      }
    }

  }

  public boolean isAlertPresent() {
    try {
      wd.switchTo ().alert ();
      return true;
    } catch (NoAlertPresentException e) {
      return false;
    }
  }
}
{'fraction_non_alphanumeric': 0.11752249867654843, 'fraction_numerical': 0.008470089994706194, 'mean_word_length': 2.9539748953974896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3755173', 'n_tokens_mistral': 655, 'n_tokens_neox': 614, 'n_words': 142}