package pl.stqa.pft.addressbook.appmanager;

import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import pl.stqa.pft.addressbook.model.GroupData;

import java.util.concurrent.TimeUnit;

public class ApplicationManager {
  FirefoxDriver wd;

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

  protected void init() {
    //wd = new FirefoxDriver();
    wd = new FirefoxDriver(new FirefoxOptions().setLegacy(true).setBinary("C:/Program Files/Mozilla Firefox/firefox.exe"));
    wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    wd.get("http://localhost/addressbook/addressbook/group.php");
    login("admin", "secret");
  }

  private void login(String username, String password) {
      wd.findElement(By.name("user")).click();
      wd.findElement(By.name("user")).clear();
      wd.findElement(By.name("user")).sendKeys(username);
      wd.findElement(By.name("pass")).click();
      wd.findElement(By.name("pass")).clear();
      wd.findElement(By.name("pass")).sendKeys(password);
      wd.findElement(By.xpath("//form[@id='LoginForm']/input[3]")).click();
  }

  protected void returnToGroupPage() {
      wd.findElement(By.linkText("group page")).click();
  }

  protected void submitGroupCreation() {
      wd.findElement(By.name("submit")).click();
  }

  protected void fillGroupForm(GroupData groupData) {
      wd.findElement(By.name("group_name")).click();
      wd.findElement(By.name("group_name")).clear();
      wd.findElement(By.name("group_name")).sendKeys(groupData.getName());
      wd.findElement(By.name("group_header")).click();
      wd.findElement(By.name("group_header")).clear();
      wd.findElement(By.name("group_header")).sendKeys(groupData.getHeader());
      wd.findElement(By.name("group_footer")).click();
      wd.findElement(By.name("group_footer")).clear();
      wd.findElement(By.name("group_footer")).sendKeys(groupData.getFooter());
  }

  protected void initGroupCreation() {
      wd.findElement(By.name("new")).click();
  }

  protected void goToGroupPage() {
      wd.findElement(By.linkText("groups")).click();
  }

  protected void stop() {
    wd.quit();
  }

  protected void deleteSelectedGroup() {
      wd.findElement(By.name("delete")).click();
  }

  protected void selectGroup() {
      if (!wd.findElement(By.name("selected[]")).isSelected()) {
          wd.findElement(By.name("selected[]")).click();
      }
  }
}

@@ -572,32 +572,29 @@
   %7D%0A  %7D%0A%0A  p
-rotected
+ublic
  void init()
@@ -925,14 +925,13 @@
 %0A  p
-rivate
+ublic
  voi
@@ -1358,32 +1358,29 @@
 ();%0A  %7D%0A%0A  p
-rotected
+ublic
  void return
@@ -1456,32 +1456,29 @@
 ();%0A  %7D%0A%0A  p
-rotected
+ublic
  void submit
@@ -1548,32 +1548,29 @@
 ();%0A  %7D%0A%0A  p
-rotected
+ublic
  void fillGr
@@ -2163,32 +2163,29 @@
 ));%0A  %7D%0A%0A  p
-rotected
+ublic
  void initGr
@@ -2250,32 +2250,29 @@
 ();%0A  %7D%0A%0A  p
-rotected
+ublic
  void goToGr
@@ -2340,32 +2340,29 @@
 ();%0A  %7D%0A%0A  p
-rotected
+ublic
  void stop()
@@ -2383,32 +2383,29 @@
 ();%0A  %7D%0A%0A  p
-rotected
+ublic
  void delete
@@ -2483,16 +2483,13 @@
 %0A  p
-rotected
+ublic
  voi

Revert "Revert "Revert "Revert "change private to public in AppManager""""