<commit_before>package com.example.fw;

import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import com.example.tests.ContactData;
import com.example.tests.GroupData;

public class ContactHelper extends HelperBase {

	public ContactHelper(ApplicationManager manager) {
		super(manager);
	}

	public void submitContactCreation() {
		click(By.name("submit"));

	}

	public void initContactCreation() {
		click(By.linkText("add new"));
	}

	public void fillContactForm(ContactData contact) {
		type(By.name("firstname"), contact.firstname);
		type(By.name("lastname"), contact.lastname);
		type(By.name("address"), contact.address1);
		type(By.name("home"), contact.home_phone1);
		type(By.name("mobile"), contact.mobile_phone);
		type(By.name("work"), contact.work_phone);
		type(By.name("email"), contact.email1);
		type(By.name("email2"), contact.email2);
		selectByText(By.name("bday"), contact.bday);
		selectByText(By.name("bmonth"), contact.bmonth);
		type(By.name("byear"), contact.byear);
		selectByText(By.name("new_group"), contact.group);
		type(By.name("address2"), contact.address2);
		type(By.name("phone2"), contact.home_phone2);
	}

	public void returnToHomePage() {
		click(By.linkText("home page"));
	}

	public void submitContactDeletion() {
		click(By.xpath("(//input[@name='update'])[2]"));

	}

	public void initContactModification(int index) {
		click(By.xpath("(//img[@alt='Edit'])[" + (index + 1) + "]"));
	}

	public void submitContactModification() {
		click(By.name("update"));

	}

	public void addContactsToGroup(int index) {
		click(By.xpath("//select[@name='to_group']/option[" + (index + 1) + "]"));
		click(By.name("add"));

	}

	public void selectContactByIndex(int index) {
		click(By.xpath("(//input[@name='selected[]'])[" + (index + 1) + "]"));
	}

	public void selectAllContactsOnPage() {
		click(By.id("MassCB"));
	}

	public void gotoContactListOfGroupByLink(String groupname) {
		click(By.linkText("group page \"" + groupname + "\""));

	}

	public void openContactListOfGroup(int index) {
		click(By.xpath("//select[@name='group']/option[" + (index + 1) + "]"));
	}

	public void openContactListOfGroup(String name) {
		selectByText(By.name("group"), name);

	}

	public void removeContactsFromGroup() {
		selectAllContactsOnPage();
		click(By.name("remove"));

	}

	public List<ContactData> getContacts() {

		List<ContactData> contacts = new ArrayList<ContactData>();
		List<WebElement> checkboxes = getListWebElements(By.name("selected[]"));

		for (WebElement checkbox : checkboxes) {
			int index = checkboxes.indexOf(checkbox);
			ContactData contact = getContactByIndex(index);
			contacts.add(contact);
		}

		return contacts;
	}

	private ContactData getContactByIndex(int index) {
		ContactData contact = new ContactData();
		contact.lastname = getWebElement(
				By.xpath("(//td[2])[" + (index + 1) + "]")).getText();
		contact.firstname = getWebElement(
				By.xpath("(//td[3])[" + (index + 1) + "]")).getText();
		contact.email1 = getWebElement(
				By.xpath("(//td[4])[" + (index + 1) + "]/a")).getText();
		return contact;
	}

	public List<GroupData> getGroupListOfCombobox(String combobox)

	{
		String choiceCombobox;
		switch (combobox) {
		case "groupListOnMainPage":
			choiceCombobox = "//select[@name='group']/option";
			break;
		case "addToGroupList":
			choiceCombobox = "//select[@name='to_group']/option";
			break;
		case "groupListOnAddContactPage":
			choiceCombobox = "//select[@name='new_group']/option";
			break;
		default:
			choiceCombobox = null;
			break;

		}
		List<GroupData> groups = new ArrayList<GroupData>();
		List<WebElement> options = getListWebElements(By.xpath(choiceCombobox));
		for (WebElement option : options) {
			GroupData group = new GroupData();
			group.name = option.getText();
			groups.add(group);

		}
		return groups;
	}

	public List<GroupData> getGroupListOfContact(int index) {
		click(By.xpath("(//img[@alt='Details'])[" + (index + 1) + "]"));
		List<GroupData> groups = new ArrayList<GroupData>();
		List<WebElement> groupnames = getListWebElements(By
				.xpath(".//*[@id='content']/i/a"));

		for (WebElement groupname : groupnames) {
			int groupIndex = groupnames.indexOf(groupname);
			GroupData group = new GroupData();
			group.name = getWebElement(
					By.xpath("//*[@id='content']/i/a["
							+ (groupIndex + 1) + "]")).getText();
					
			if (group.name.equals(null)) {

				group.name = "";
			}
<commit_msg>Домашнее задание 6 (работа над ошибками)<commit_after>package com.example.fw;

import java.util.ArrayList;
import java.util.List;

import javax.swing.RowFilter;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import com.example.tests.ContactData;
import com.example.tests.GroupData;

public class ContactHelper extends HelperBase {

	public ContactHelper(ApplicationManager manager) {
		super(manager);
	}

	public void submitContactCreation() {
		click(By.name("submit"));

	}

	public void initContactCreation() {
		click(By.linkText("add new"));
	}

	public void fillContactForm(ContactData contact) {
		type(By.name("firstname"), contact.firstname);
		type(By.name("lastname"), contact.lastname);
		type(By.name("address"), contact.address1);
		type(By.name("home"), contact.home_phone1);
		type(By.name("mobile"), contact.mobile_phone);
		type(By.name("work"), contact.work_phone);
		type(By.name("email"), contact.email1);
		type(By.name("email2"), contact.email2);
		selectByText(By.name("bday"), contact.bday);
		selectByText(By.name("bmonth"), contact.bmonth);
		type(By.name("byear"), contact.byear);
		selectByText(By.name("new_group"), contact.group);
		type(By.name("address2"), contact.address2);
		type(By.name("phone2"), contact.home_phone2);
	}

	public void returnToHomePage() {
		click(By.linkText("home page"));
	}

	public void submitContactDeletion() {
		click(By.xpath("(//input[@name='update'])[2]"));

	}

	public void initContactModification(int index) {
		click(By.xpath("(//img[@alt='Edit'])[" + (index + 1) + "]"));
	}

	public void submitContactModification() {
		click(By.name("update"));

	}

	public void addContactsToGroup(int index) {
		click(By.xpath("//select[@name='to_group']/option[" + (index + 1) + "]"));
		click(By.name("add"));

	}

	public void selectContactByIndex(int index) {
		click(By.xpath("(//input[@name='selected[]'])[" + (index + 1) + "]"));
	}

	public void selectAllContactsOnPage() {
		click(By.id("MassCB"));
	}

	public void gotoContactListOfGroupByLink(String groupname) {
		click(By.linkText("group page \"" + groupname + "\""));

	}

	public void openContactListOfGroup(int index) {
		click(By.xpath("//select[@name='group']/option[" + (index + 1) + "]"));
	}

	public void openContactListOfGroup(String name) {
		selectByText(By.name("group"), name);

	}

	public void removeContactsFromGroup() {
		selectAllContactsOnPage();
		click(By.name("remove"));

	}

	public List<ContactData> getContacts() {

		List<ContactData> contacts = new ArrayList<ContactData>();
		List<WebElement> rows = driver.findElements(By
				.xpath("(//tr[@name='entry'])"));

		for (WebElement row : rows) {
			int index = rows.indexOf(row);
			ContactData contact = getContactByIndex(index);
			contacts.add(contact);
		}

		return contacts;
	}

	private ContactData getContactByIndex(int index) {
		ContactData contact = new ContactData();
		contact.lastname = getWebElement(
				By.xpath("(//td[2])[" + (index + 1) + "]")).getText();
		contact.firstname = getWebElement(
				By.xpath("(//td[3])[" + (index + 1) + "]")).getText();
		contact.email1 = getWebElement(
				By.xpath("(//td[4])[" + (index + 1) + "]/a")).getText();
		return contact;
	}

	public List<GroupData> getGroupListOfCombobox(String combobox)

	{
		String choiceCombobox;
		switch (combobox) {
		case "groupListOnMainPage":
			choiceCombobox = "//select[@name='group']/option";
			break;
		case "addToGroupList":
			choiceCombobox = "//select[@name='to_group']/option";
			break;
		case "groupListOnAddContactPage":
			choiceCombobox = "//select[@name='new_group']/option";
			break;
		default:
			choiceCombobox = null;
			break;

		}
		List<GroupData> groups = new ArrayList<GroupData>();
		List<WebElement> options = getListWebElements(By.xpath(choiceCombobox));
		for (WebElement option : options) {
			GroupData group = new GroupData();
			group.name = option.getText();
			groups.add(group);

		}
		return groups;
	}

	public List<GroupData> getGroupListOfContact(int index) {
		click(By.xpath("(//img[@alt='Details'])[" + (index + 1) + "]"));
		List<GroupData> groups = new ArrayList<GroupData>();
		List<WebElement> groupnames = getListWebElements(By
				.xpath(".//*[@id='content']/i/a"));

		for (WebElement groupname : groupnames) {
			int groupIndex = groupnames.indexOf(groupname);
			GroupData group = new GroupData();
			group.name = getWebElement(
					By.xpath("//*[@id='content']/i/a[" + (groupIndex + 1) + "]"))
					.getText();

			if (group.name.equals(null)) {

				group.name = "";
			}

{'fraction_non_alphanumeric': 0.18041123148352864, 'fraction_numerical': 0.005195666592969268, 'mean_word_length': 4.75875238701464, 'pattern_counts': {'":': 6, '<': 27, '<?xml version=': 0, '>': 27, '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': '5216741', 'n_tokens_mistral': 3404, 'n_tokens_neox': 3049, 'n_words': 530}