当前位置: 首页>>代码示例>>Java>>正文


Java FindsByXPath类代码示例

本文整理汇总了Java中org.openqa.selenium.internal.FindsByXPath的典型用法代码示例。如果您正苦于以下问题:Java FindsByXPath类的具体用法?Java FindsByXPath怎么用?Java FindsByXPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FindsByXPath类属于org.openqa.selenium.internal包,在下文中一共展示了FindsByXPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findElements

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public List<WebElement> findElements(SearchContext searchContext) {
    logger.finer("finding label " + label + " in " + searchContext);
    String safeLabel;
    if (label.contains("'")) {
        // replace each ' with ', "'", ' so we can use it in a concat expression
        // makes concat('O', "'", 'Neil') from O'Neil
        safeLabel = "concat('" + label.replace("'", "', \"'\", '") + "')";
    } else {
        safeLabel = "'" + label + "'";
    }
    // start from . for instances where we are searching within a scoped element
    // tr elements having a _afrrk (rowkey) attribute are considered tree nodes
    String xpath = ".//tr[@_afrrk and .//span[text()=" + safeLabel + "]]";
    logger.finer("using xpath " + xpath);
    return ((FindsByXPath) searchContext).findElementsByXPath(xpath);
}
 
开发者ID:adfemg,项目名称:adf-selenium,代码行数:18,代码来源:AdfFinder.java

示例2: findElements

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public List<WebElement> findElements(SearchContext context) {
    long t0 = System.currentTimeMillis();
    try {
        return ((FindsByXPath) context)
                .findElementsByXPath(ownXpathExpression);
    } finally {
        long l = System.currentTimeMillis()-t0;
        if (l > 100) {
            LOG.warn("SLOW findElements() = {}ms. Slow selector : {} ", l,  ownXpathExpression);
        }
    }
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:14,代码来源:ByExtended.java

示例3: findElement

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public WebElement findElement(SearchContext context) {
    long t0 = System.currentTimeMillis();
    try {
        int indexOf = ownXpathExpression.indexOf("//", 3);
        if (indexOf > -1) { // we found an // inside the selector
            String[] splitSelectors = ownXpathExpression.substring(2).split(Pattern.quote("//"));

            WebElement parent = ((FindsByXPath) context).findElementByXPath("//"+splitSelectors[0]);
            for (int i = 1; i < splitSelectors.length; i++) {
                if (parent == null) {
                    throw new WebDriverException("Failed to match the parent selector : "+splitSelectors[i-1]);
                }
                WebElement found = parent.findElement(By.xpath(".//"+splitSelectors[i]));
                if (found != null) {
                    parent = found;
                } else {
                    throw new WebDriverException("Failed to match the selector : "+splitSelectors[i]+" within "+ownXpathExpression);
                }
            }

            // by here, we should have the parent WebElement to contain what we want.
            //LOG.info("Found compound selector : "+parent.toString());
            return parent;
        }
        // simple case: one selector
        return ((FindsByXPath) context).findElementByXPath(ownXpathExpression);
    } finally {
        long l = System.currentTimeMillis()-t0;
        if (l > 100) {
            LOG.warn("SLOW findElement() = {}ms. Slow selector : {} ", l,  ownXpathExpression);
        }
    }
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:35,代码来源:ByExtended.java

示例4: findElements

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public List<WebElement> findElements(SearchContext context) {
	long t0 = System.currentTimeMillis();
	try {
		return ((FindsByXPath) context)
			.findElementsByXPath(ownXpathExpression);
	} finally {
		long l = System.currentTimeMillis()-t0;
		if (l > 100) {
			LOG.warn("SLOW findElements() = {}ms. Slow selector : {} ", l,  ownXpathExpression);
		}
	}
}
 
开发者ID:persado,项目名称:stevia,代码行数:14,代码来源:ByExtended.java

示例5: findElement

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public WebElement findElement(SearchContext context) {
	long t0 = System.currentTimeMillis();
	try {
		int indexOf = ownXpathExpression.indexOf("//", 3);
		if (indexOf > -1) { // we found an // inside the selector
			String[] splitSelectors = ownXpathExpression.substring(2).split(Pattern.quote("//"));
			
			WebElement parent = ((FindsByXPath) context).findElementByXPath("//"+splitSelectors[0]);
			for (int i = 1; i < splitSelectors.length; i++) {
				if (parent == null) {
					throw new WebDriverException("Failed to match the parent selector : "+splitSelectors[i-1]);
				}
				WebElement found = parent.findElement(By.xpath(".//"+splitSelectors[i]));
				if (found != null) {
					parent = found;
				} else {
					throw new WebDriverException("Failed to match the selector : "+splitSelectors[i]+" within "+ownXpathExpression);
				}
			}
			
			// by here, we should have the parent WebElement to contain what we want.
			//LOG.info("Found compound selector : "+parent.toString());
			return parent;
		}
		// simple case: one selector
		return ((FindsByXPath) context).findElementByXPath(ownXpathExpression);
	} finally {
		long l = System.currentTimeMillis()-t0;
		if (l > 100) {
			LOG.warn("SLOW findElement() = {}ms. Slow selector : {} ", l,  ownXpathExpression);
		}
	}
}
 
开发者ID:persado,项目名称:stevia,代码行数:35,代码来源:ByExtended.java

示例6: RobustElementWrapper

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
/**
 * Main robust web element constructor
 * 
 * @param element element reference to be wrapped (may be 'null')
 * @param context element search context
 * @param locator element locator
 * @param index element index
 */
public RobustElementWrapper(WebElement element, WrapsContext context, By locator, int index) {
    
    // if specified element is already robust
    if (element instanceof RobustWebElement) {
        RobustElementWrapper wrapper = ((InterceptionAccessor) element).getInterceptor();
        this.acquiredAt = wrapper.acquiredAt;
        
        this.wrapped = wrapper.wrapped;
        this.context = wrapper.context;
        this.locator = wrapper.locator;
        this.index = wrapper.index;
    } else {
        Objects.requireNonNull(context, "[context] must be non-null");
        Objects.requireNonNull(locator, "[locator] must be non-null");
        if (index < OPTIONAL) {
            throw new IndexOutOfBoundsException("Specified index is invalid");
        }
        
        this.wrapped = element;
        this.context = context;
        this.locator = locator;
        this.index = index;
    }
    
    driver = WebDriverUtils.getDriver(this.context.getWrappedContext());
    
    findsByCssSelector = (driver instanceof FindsByCssSelector);
    findsByXPath = (driver instanceof FindsByXPath);
    
    if ((this.index == OPTIONAL) || (this.index > 0)) {
        if (findsByXPath && ( ! (this.locator instanceof By.ByCssSelector))) {
            selector = ByType.xpathLocatorFor(this.locator);
            if (this.index > 0) {
                selector += "[" + (this.index + 1) + "]";
            }
            strategy = Strategy.JS_XPATH;
            
            this.locator = By.xpath(this.selector);
        } else if (findsByCssSelector) {
            selector = ByType.cssLocatorFor(this.locator);
            if (selector != null) {
                strategy = Strategy.JS_CSS;
            }
        }
    }
    
    if (this.wrapped == null) {
        if (this.index == OPTIONAL) {
            acquireReference(this);
        } else {
            refreshReference(null);
        }
    } else if (acquiredAt == 0) {
        acquiredAt = System.currentTimeMillis();
    }
}
 
开发者ID:Nordstrom,项目名称:Selenium-Foundation,代码行数:65,代码来源:RobustElementFactory.java

示例7: findElementByXPath

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
/**
 * Finds element by xpath.
 */
@Override
public WebElement findElementByXPath(String xPath) {
  return ((FindsByXPath) super.getWrappedDriver()).findElementByXPath(xPath);
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:8,代码来源:WebDriverWrapper.java

示例8: findElementsByXPath

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
/**
 * Finds elements by xpath.
 */
@Override
public List<WebElement> findElementsByXPath(String xPath) {
  return ((FindsByXPath) super.getWrappedDriver()).findElementsByXPath(xPath);
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:8,代码来源:WebDriverWrapper.java

示例9: findElements

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public List<WebElement> findElements(SearchContext context) {
	return ((FindsByXPath) context).findElementsByXPath(xpathExpression);
}
 
开发者ID:jhc-systems,项目名称:redsniff,代码行数:5,代码来源:ByWicketPath.java

示例10: findElement

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public WebElement findElement(SearchContext context) {
	return ((FindsByXPath) context).findElementByXPath(xpathExpression);
}
 
开发者ID:jhc-systems,项目名称:redsniff,代码行数:5,代码来源:ByWicketPath.java

示例11: findElements

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public List<WebElement> findElements(SearchContext context) {
  return ((FindsByXPath) context).findElementsByXPath(".//*["
      + attributeContains(attribute, word) + "]");
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:6,代码来源:ByPartialAttribute.java

示例12: findElement

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public WebElement findElement(SearchContext context) {
  return ((FindsByXPath) context).findElementByXPath(".//*["
      + attributeContains(attribute, word) + "]");
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:6,代码来源:ByPartialAttribute.java

示例13: findElements

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public List<WebElement> findElements(SearchContext context) {
  return ((FindsByXPath) context).findElementsByXPath(".//*["
      + attributeEquals(attribute, word) + "]");
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:6,代码来源:ByAttribute.java

示例14: findElement

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public WebElement findElement(SearchContext context) {
  return ((FindsByXPath) context).findElementByXPath(".//*["
      + attributeEquals(attribute, word) + "]");
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:6,代码来源:ByAttribute.java

示例15: findElements

import org.openqa.selenium.internal.FindsByXPath; //导入依赖的package包/类
@Override
public List<WebElement> findElements(SearchContext context) {
    return ((FindsByXPath) context).findElementsByXPath(".//*["
            + textContains(text) + "]");
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:6,代码来源:ByPartialVisibleText.java


注:本文中的org.openqa.selenium.internal.FindsByXPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。