本文整理了Java中org.openqa.selenium.support.FindBy.using()
方法的一些代码示例,展示了FindBy.using()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FindBy.using()
方法的具体详情如下:
包路径:org.openqa.selenium.support.FindBy
类名称:FindBy
方法名:using
暂无
代码示例来源:origin: stackoverflow.com
String using = findBy.using();
代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support
private void assertValidFindBy(FindBy findBy) {
if (findBy.how() != null) {
if (findBy.using() == null) {
throw new IllegalArgumentException("If you set the 'how' property, you must also set 'using'");
}
}
Set<String> finders = new HashSet<String>();
if (!"".equals(findBy.using())) finders.add("how: " + findBy.using());
if (!"".equals(findBy.className())) finders.add("class name:" + findBy.className());
if (!"".equals(findBy.id())) finders.add("id: " + findBy.id());
if (!"".equals(findBy.linkText())) finders.add("link text: " + findBy.linkText());
if (!"".equals(findBy.name())) finders.add("name: " + findBy.name());
if (!"".equals(findBy.partialLinkText())) finders.add("partial link text: " + findBy.partialLinkText());
if (!"".equals(findBy.tagName())) finders.add("tag name: " + findBy.tagName());
if (!"".equals(findBy.xpath())) finders.add("xpath: " + findBy.xpath());
// A zero count is okay: it means to look by name or id.
if (finders.size() > 1) {
throw new IllegalArgumentException(
String.format("You must specify at most one location strategy. Number found: %d (%s)",
finders.size(), finders.toString()));
}
}
}
代码示例来源:origin: stackoverflow.com
private static class CustomFindByAnnotations extends Annotations {
protected By buildByFromLongFindBy(FindBy findBy) {
How how = findBy.how();
String using = findBy.using();
switch (how) {
case CLASS_NAME:
return By.className(using);
case ID:
return By.id(using); // By.name(using); in your case
case ID_OR_NAME:
return new ByIdOrName(using);
case LINK_TEXT:
return By.linkText(using);
case NAME:
return By.name(using);
case PARTIAL_LINK_TEXT:
return By.partialLinkText(using);
case TAG_NAME:
return By.tagName(using);
case XPATH:
return By.xpath(using);
default:
throw new IllegalArgumentException("Cannot determine how to locate element " + field);
}
}
}
代码示例来源:origin: org.jboss.arquillian.graphene/graphene-webdriver-impl
private int assertValidFindBy(FindBy findBy) {
if (findBy.how() != null) {
if (findBy.using() == null) {
throw new IllegalArgumentException("If you set the 'how' property, you must also set 'using'");
if (!"".equals(findBy.using())) {
finders.add("how: " + findBy.using());
代码示例来源:origin: arachnidium/arachnidium-java
private static By getPossibleChain(RootElement rootElement){
List<By> result = new ArrayList<>();
FindBy[] findBies = rootElement.chain();
for (FindBy findBy: findBies) {
By by = null;
by = getBy(findBy);
if (by != null){
result.add(by);
continue;
}
result.add(getBy(findBy.how(), findBy.using()));
}
return new ByNumbered(new ByChained(result.toArray(new By[]{})), rootElement.index());
}
代码示例来源:origin: arquillian/arquillian-graphene
private int assertValidFindBy(FindBy findBy) {
if (findBy.how() != null) {
if (findBy.using() == null) {
throw new IllegalArgumentException("If you set the 'how' property, you must also set 'using'");
if (!"".equals(findBy.using())) {
finders.add("how: " + findBy.using());
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support
public By buildBy() {
How how = How.ID_OR_NAME;
String using = field.getName();
FindBy findBy = field.getAnnotation(FindBy.class);
if (findBy != null) {
how = findBy.how();
using = findBy.using();
}
switch (how) {
case CLASS_NAME:
return By.className(using);
case ID:
return By.id(using);
case ID_OR_NAME:
return new ByIdOrName(using);
case LINK_TEXT:
return By.linkText(using);
case NAME:
return By.name(using);
case PARTIAL_LINK_TEXT:
return By.partialLinkText(using);
case TAG_NAME:
return By.tagName(using);
case XPATH:
return By.xpath(using);
default:
throw new IllegalArgumentException("Cannot determine how to locate element");
}
}
代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support
protected By buildByFromLongFindBy(FindBy findBy) {
How how = findBy.how();
String using = findBy.using();
switch (how) {
case CLASS_NAME:
return By.className(using);
case ID:
return By.id(using);
case ID_OR_NAME:
return new ByIdOrName(using);
case LINK_TEXT:
return By.linkText(using);
case NAME:
return By.name(using);
case PARTIAL_LINK_TEXT:
return By.partialLinkText(using);
case TAG_NAME:
return By.tagName(using);
case XPATH:
return By.xpath(using);
default:
// Note that this shouldn't happen (eg, the above matches all
// possible values for the How enum)
throw new IllegalArgumentException("Cannot determine how to locate element " + field);
}
}
代码示例来源:origin: org.jboss.arquillian.graphene/graphene-webdriver-impl
protected By buildByFromLongFindBy(FindBy findBy) {
How how = findBy.how();
String using = findBy.using();
switch (how) {
case CLASS_NAME:
return By.className(using);
case CSS:
return By.cssSelector(using);
case ID:
return By.id(using);
case ID_OR_NAME:
return new ByIdOrName(using);
case LINK_TEXT:
return By.linkText(using);
case NAME:
return By.name(using);
case PARTIAL_LINK_TEXT:
return By.partialLinkText(using);
case TAG_NAME:
return By.tagName(using);
case XPATH:
return By.xpath(using);
default:
// Note that this shouldn't happen (eg, the above matches all
// possible values for the How enum)
throw new IllegalArgumentException("Cannot determine how to locate element " + field);
}
}
代码示例来源:origin: arquillian/arquillian-graphene
protected By buildByFromLongFindBy(FindBy findBy) {
How how = findBy.how();
String using = findBy.using();
switch (how) {
case CLASS_NAME:
return By.className(using);
case CSS:
return By.cssSelector(using);
case ID:
return By.id(using);
case ID_OR_NAME:
return new ByIdOrName(using);
case LINK_TEXT:
return By.linkText(using);
case NAME:
return By.name(using);
case PARTIAL_LINK_TEXT:
return By.partialLinkText(using);
case TAG_NAME:
return By.tagName(using);
case XPATH:
return By.xpath(using);
default:
// Note that this shouldn't happen (eg, the above matches all
// possible values for the How enum)
throw new IllegalArgumentException("Cannot determine how to locate element " + field);
}
}
内容来源于网络,如有侵权,请联系作者删除!