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

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

There is a newer version: 1.0.1-37
Show newest version

package com.slickqa.webdriver.finders;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.ArrayList;
import java.util.Arrays;

/**
 *
 * @author slambson
 */
public class FindByText extends AbstractFindByParentBy
{
	String text;

	public FindByText(String text)
	{
		this.text = text;
	}

	@Override
	public String toString()
	{
		return String.format("By text '%s'.", text);
	}

	@Override
	public boolean matches(WebElement e)
	{
		String textValue = e.getText();
		return textValue != null && textValue.equals(text);
	}

	@Override
	public ArrayList getParentBy()
	{
		return new ArrayList(Arrays.asList(tagName("label"), tagName("div"), tagName("h1"), tagName("h2"), tagName("h3")));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy