package at.porscheinformatik.seleniumcomponents;

import static org.hamcrest.Matchers.*;

import org.openqa.selenium.WebElement;

/**
 * A {@link SeleniumComponent} that is clickable.
 *
 * @author ham
 */
public interface ClickableSeleniumComponent extends VisibleSeleniumComponent
{

    /**
     * Returns true if the component is clickable. Waits {@link SeleniumGlobals#getShortTimeoutInSeconds()} seconds for
     * the component to become available.
     *
     * @return true if clickable
     */
    default boolean isClickable()
    {
        try
        {
            return SeleniumUtils.retryOnStale(() -> {
                WebElement element = element();

                return element.isDisplayed() && element.isEnabled();
            });
        }
        catch (Exception e)
        {
            return false;
        }
    }

    /**
     * Waits {@link SeleniumGlobals#getShortTimeoutInSeconds()} seconds for the component to become clickable and clicks
     * it.
     */
    default void click()
    {
        LOG.interaction("Clicking on %s", describe());

        SeleniumAsserts.assertThatSoon(() -> {
            if (this.isClickable())
            {
                element().click();

                return true;
            }

            return false;
        }, is(true));
    }

}

@@ -863,58 +863,352 @@
 its 
-%7B@link SeleniumGlobals#getShortTimeoutInSeconds()%7D
+5 seconds for the component to become clickable and clicks it. We use a bit more than the default short%0A     * timeout because it is possible, that selecting a element needs a few seconds to complete. Depending on the%0A     * Component Hirarchy used.%0A     */%0A    default void click()%0A    %7B%0A        click(5);%0A    %7D%0A%0A    /**%0A     * Waits the given
  sec
@@ -1260,24 +1260,28 @@
 d clicks
+ it.
 %0A     * 
 it.%0A    
@@ -1272,19 +1272,100 @@
 %0A     * 
-it.
+%0A     * @param timeoutInSeconds the amount of time to wait until the operation fails
 %0A     */
@@ -1380,32 +1380,53 @@
 ault void click(
+long timeoutInSeconds
 )%0A    %7B%0A        
@@ -1512,16 +1512,34 @@
 hatSoon(
+timeoutInSeconds, 
 () -%3E %7B%0A

Increase default timeout