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

com.slickqa.webdriver.finders.FindByHref Maven / Gradle / Ivy

There is a newer version: 1.0.1-37
Show newest version
package com.slickqa.webdriver.finders;

import java.util.ArrayList;
import java.util.Arrays;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

/**
 *
 * @author slambson
 */
public class FindByHref extends AbstractFindByParentBy
{
	private String hrefText;

	public FindByHref(String hrefText)
	{
		this.hrefText = hrefText;
	}

	@Override
	public boolean matches(WebElement e)
	{
		String attrValue = e.getAttribute("href");
		return attrValue != null && attrValue.equals(hrefText);
	}

	@Override
	public ArrayList getParentBy()
	{
		return new ArrayList(Arrays.asList(tagName("a")));
	}

	@Override
	public String toString()
	{
		return String.format("By href attribute matching '%s'.", hrefText);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy