/*
 * Copyright (c) 2014 mgm technology partners GmbH
 *
 * 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.
 */
package com.mgmtp.jfunk.web.util;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Function;
import com.google.common.base.Predicate;

/**
 * {@link WebDriverWait} decendant that writes a log message before {@link #until(Function)} or
 * {@link #until(Predicate)} is called.
 * 
 * @author rnaegele
 */
public class LoggingWebDriverWait extends WebDriverWait {

	private final Logger log = LoggerFactory.getLogger(getClass());

	public LoggingWebDriverWait(final WebDriver driver, final long timeOutInSeconds) {
		super(driver, timeOutInSeconds);
	}

	public LoggingWebDriverWait(final WebDriver driver, final long timeOutInSeconds, final long sleepInMillis) {
		super(driver, timeOutInSeconds, sleepInMillis);
	}

	@Override
	public <V> V until(final Function<? super WebDriver, V> function) {
		log.info("Waiting for {}", function);
		V result = super.until(function);
		log.info("Successfully waited for {}", function);
		return result;
	}

	@Override
	protected RuntimeException timeoutException(final String message, final Throwable lastException) {
		log.error(message);
		return super.timeoutException(message, lastException);
	}
}

@@ -644,16 +644,145 @@
 .util;%0A%0A
+import java.util.List;%0A%0Aimport org.openqa.selenium.NotFoundException;%0Aimport org.openqa.selenium.StaleElementReferenceException;%0A
 import o
@@ -807,24 +807,24 @@
 .WebDriver;%0A
-
 import org.o
@@ -1002,16 +1002,64 @@
 edicate;
+%0Aimport com.google.common.collect.ImmutableList;
 %0A%0A/**%0A *
@@ -1277,16 +1277,232 @@
 erWait %7B
+%0A%09private static final List%3CClass%3C? extends Throwable%3E%3E IGNORED_EXCEPTIONS = ImmutableList.%3CClass%3C? extends Throwable%3E%3Eof(%0A%09%09%09NotFoundException.class, WebElementException.class, StaleElementReferenceException.class);
 %0A%0A%09priva
@@ -1643,29 +1643,28 @@
 econds) %7B%0A%09%09
-super
+this
 (driver, tim
@@ -1676,16 +1676,53 @@
 nSeconds
+, WebDriverWait.DEFAULT_SLEEP_TIMEOUT
 );%0A%09%7D%0A%0A%09
@@ -1830,16 +1830,16 @@
 llis) %7B%0A
-
 %09%09super(
@@ -1880,16 +1880,49 @@
 illis);%0A
+%09%09ignoreAll(IGNORED_EXCEPTIONS);%0A
 %09%7D%0A%0A%09@Ov

Add ignored exceptions as in WebElementFinder