/*
 * #%L
 * wcm.io
 * %%
 * Copyright (C) 2018 wcm.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package io.wcm.qa.galenium.interaction;

import static io.wcm.qa.galenium.reporting.GaleniumReportUtil.getLogger;
import static io.wcm.qa.galenium.util.GaleniumContext.getDriver;

import org.apache.commons.lang3.StringUtils;

import io.wcm.qa.galenium.util.GaleniumContext;

/**
 * Alert related convenience methods.
 */
public final class Browser {

  private Browser() {
    // do not instantiate
  }

  /**
   * Load URL in browser and fail test if URL does not match.
   * @param url to load
   */
  public static void loadExactly(String url) {
    load(url);
    GaleniumContext.getAssertion().assertEquals(url, getDriver().getCurrentUrl(), "Current URL should match.");
  }

  /**
   * Load URL in browser.
   * @param url to load
   */
  public static void load(String url) {
    getLogger().trace("loading URL: '" + url + "'");
    getDriver().get(url);
  }

  /**
   * @param url to check against
   * @return whether browser is currently pointing at URL
   */
  public static boolean isCurrentUrl(String url) {
    return StringUtils.equals(url, getDriver().getCurrentUrl());
  }

}

@@ -801,16 +801,38 @@
 river;%0A%0A
+import java.net.URL;%0A%0A
 import o
@@ -1062,199 +1062,388 @@
   * 
-Load URL in browser and fail test if URL does not match.%0A   * @param url to load%0A   */%0A  public static void loadExactly(String url) %7B%0A    load(url);%0A    GaleniumContext.getAssertion().assertE
+Navigate back.%0A   */%0A  public static void back() %7B%0A    getDriver().navigate().back();%0A  %7D%0A%0A  /**%0A   * Navigate forward.%0A   */%0A  public static void forward() %7B%0A    getDriver().navigate().forward();%0A  %7D%0A%0A  /**%0A   * @param url to check against%0A   * @return whether browser is currently pointing at URL%0A   */%0A  public static boolean isCurrentUrl(String url) %7B%0A    return StringUtils.e
 qual
@@ -1480,37 +1480,8 @@
 rl()
-, %22Current URL should match.%22
 );%0A 
@@ -1685,93 +1685,339 @@
   * 
-@param url to check against%0A   * @return whether browser is currently pointing at URL
+Load URL in browser and fail test if URL does not match.%0A   * @param url to load%0A   */%0A  public static void loadExactly(String url) %7B%0A    load(url);%0A    GaleniumContext.getAssertion().assertEquals(url, getDriver().getCurrentUrl(), %22Current URL should match.%22);%0A  %7D%0A%0A  /**%0A   * Navigate to URL.%0A   * @param string URL to navigate to
 %0A   
@@ -2039,36 +2039,31 @@
 tic 
-boolean isCurrentUrl
+void navigateTo
 (String 
 url)
@@ -2054,35 +2054,38 @@
 teTo(String 
-url
+string
 ) %7B%0A    
 return Strin
@@ -2076,72 +2076,304 @@
     
-return StringUtils.equals(url, getDriver().getCurrentUrl()
+getDriver().navigate().to(string);%0A  %7D%0A%0A  /**%0A   * Navigate to URL.%0A   * @param url to navigate to%0A   */%0A  public static void navigateTo(URL url) %7B%0A    getDriver().navigate().to(url);%0A  %7D%0A%0A  /**%0A   * Refresh browser.%0A   */%0A  public static void refresh() %7B%0A    getDriver().navigate().refresh(
 );%0A  %7D%0A
-%0A
 %7D%0A

add more browser convenience