All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.selophane.elements.widget.LinkImpl Maven / Gradle / Ivy

There is a newer version: 0.12
Show newest version
/**
 * 
 */
package org.selophane.elements.widget;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.selophane.elements.base.ElementImpl;
import org.selophane.elements.base.UniqueElementLocator;

/**
 * The implementation of a link.
 * 
 * @author niels
 *
 */
public class LinkImpl extends ElementImpl implements Link {

    private final WebDriver webDriver;

    /**
     * @param elementLocator
     */
    public LinkImpl(UniqueElementLocator elementLocator) {
        super(elementLocator);
        this.webDriver = elementLocator.getWebDriver();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getLabel() {
        return getText();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getLinkUrl() {
        return getWrappedElement().getAttribute("href");
    }

    @Override
    public void click() {
        final WebDriverWait wait = new WebDriverWait(webDriver, 10);
        final WebElement button = getWrappedElement();
        button.click();
        wait.until(ExpectedConditions.stalenessOf(button));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy