org.openqa.selenium.support.FindBy.xpath()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.openqa.selenium.support.FindBy.xpath()方法的一些代码示例,展示了FindBy.xpath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FindBy.xpath()方法的具体详情如下:
包路径:org.openqa.selenium.support.FindBy
类名称:FindBy
方法名:xpath

FindBy.xpath介绍

暂无

代码示例

代码示例来源: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: arquillian/arquillian-graphene

finders.add("tag name: " + findBy.tagName());
if (!"".equals(findBy.xpath())) {
  finders.add("xpath: " + findBy.xpath());

代码示例来源:origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

finders.add("tag name: " + findBy.tagName());
if (!"".equals(findBy.xpath())) {
  finders.add("xpath: " + findBy.xpath());

代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support

protected By buildByFromShortFindBy(FindBy findBy) {
 if (!"".equals(findBy.className()))
  return By.className(findBy.className());
 if (!"".equals(findBy.id()))
  return By.id(findBy.id());
 if (!"".equals(findBy.linkText()))
  return By.linkText(findBy.linkText());
 if (!"".equals(findBy.name()))
  return By.name(findBy.name());
 if (!"".equals(findBy.partialLinkText()))
  return By.partialLinkText(findBy.partialLinkText());
 if (!"".equals(findBy.tagName()))
  return By.tagName(findBy.tagName());
 if (!"".equals(findBy.xpath()))
  return By.xpath(findBy.xpath());
 // Fall through
 return null;
}

代码示例来源:origin: arachnidium/arachnidium-java

private static By getBy(FindBy findBy) {
  if (!"".equals(findBy.className()))
    return By.className(findBy.className());
  if (!"".equals(findBy.css()))
    return By.cssSelector(findBy.css());
  if (!"".equals(findBy.id()))
    return By.id(findBy.id());
  if (!"".equals(findBy.linkText()))
    return By.linkText(findBy.linkText());
  if (!"".equals(findBy.name()))
    return By.name(findBy.name());
  if (!"".equals(findBy.partialLinkText()))
    return By.partialLinkText(findBy.partialLinkText());
  if (!"".equals(findBy.tagName()))
    return By.tagName(findBy.tagName());
  if (!"".equals(findBy.xpath()))
    return By.xpath(findBy.xpath());
  return null;
}

代码示例来源:origin: com.epam.jdi/jdi-uitest-web

public static By findByToBy(FindBy locator) {
  if (locator == null) return null;
  if (!locator.id().isEmpty())
    return By.id(locator.id());
  if (!locator.className().isEmpty())
    return By.className(locator.className());
  if (!locator.xpath().isEmpty())
    return By.xpath(locator.xpath());
  if (!locator.css().isEmpty())
    return By.cssSelector(locator.css());
  if (!locator.linkText().isEmpty())
    return By.linkText(locator.linkText());
  if (!locator.name().isEmpty())
    return By.name(locator.name());
  if (!locator.partialLinkText().isEmpty())
    return By.partialLinkText(locator.partialLinkText());
  if (!locator.tagName().isEmpty())
    return By.tagName(locator.tagName());
  return null;
}

代码示例来源:origin: epam/JDI

public static By findByToBy(FindBy locator) {
  if (locator == null) return null;
  if (!"".equals(locator.id()))
    return By.id(locator.id());
  if (!"".equals(locator.className()))
    return By.className(locator.className());
  if (!"".equals(locator.xpath()))
    return By.xpath(locator.xpath());
  if (!"".equals(locator.css()))
    return By.cssSelector(locator.css());
  if (!"".equals(locator.linkText()))
    return By.linkText(locator.linkText());
  if (!"".equals(locator.name()))
    return By.name(locator.name());
  if (!"".equals(locator.partialLinkText()))
    return By.partialLinkText(locator.partialLinkText());
  if (!"".equals(locator.tagName()))
    return By.tagName(locator.tagName());
  return null;
}

代码示例来源:origin: epam/JDI

public static By findByToBy(FindBy locator) {
  if (locator == null) return null;
  if (!locator.id().isEmpty())
    return By.id(locator.id());
  if (!locator.className().isEmpty())
    return By.className(locator.className());
  if (!locator.xpath().isEmpty())
    return By.xpath(locator.xpath());
  if (!locator.css().isEmpty())
    return By.cssSelector(locator.css());
  if (!locator.linkText().isEmpty())
    return By.linkText(locator.linkText());
  if (!locator.name().isEmpty())
    return By.name(locator.name());
  if (!locator.partialLinkText().isEmpty())
    return By.partialLinkText(locator.partialLinkText());
  if (!locator.tagName().isEmpty())
    return By.tagName(locator.tagName());
  return null;
}

代码示例来源:origin: com.epam.jdi/jdi-light

public static By findByToBy(org.openqa.selenium.support.FindBy locator) {
  if (locator == null) return null;
  if (!locator.id().isEmpty())
    return By.id(locator.id());
  if (!locator.className().isEmpty())
    return By.className(locator.className());
  if (!locator.xpath().isEmpty())
    return By.xpath(locator.xpath());
  if (!locator.css().isEmpty())
    return By.cssSelector(locator.css());
  if (!locator.linkText().isEmpty())
    return By.linkText(locator.linkText());
  if (!locator.name().isEmpty())
    return By.name(locator.name());
  if (!locator.partialLinkText().isEmpty())
    return By.partialLinkText(locator.partialLinkText());
  if (!locator.tagName().isEmpty())
    return By.tagName(locator.tagName());
  return null;
}

代码示例来源:origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

protected By buildByFromShortFindBy(FindBy findBy) {
  if (!"".equals(findBy.className())) {
    return By.className(findBy.className());
  }
  if (!"".equals(findBy.css())) {
    return By.cssSelector(findBy.css());
  }
  if (!"".equals(findBy.id())) {
    return By.id(findBy.id());
  }
  if (!"".equals(findBy.linkText())) {
    return By.linkText(findBy.linkText());
  }
  if (!"".equals(findBy.name())) {
    return By.name(findBy.name());
  }
  if (!"".equals(findBy.partialLinkText())) {
    return By.partialLinkText(findBy.partialLinkText());
  }
  if (!"".equals(findBy.tagName())) {
    return By.tagName(findBy.tagName());
  }
  if (!"".equals(findBy.xpath())) {
    return By.xpath(findBy.xpath());
  }
  // Fall through
  return null;
}

代码示例来源:origin: arquillian/arquillian-graphene

protected By buildByFromShortFindBy(FindBy findBy) {
  if (!"".equals(findBy.className())) {
    return By.className(findBy.className());
  }
  if (!"".equals(findBy.css())) {
    return By.cssSelector(findBy.css());
  }
  if (!"".equals(findBy.id())) {
    return By.id(findBy.id());
  }
  if (!"".equals(findBy.linkText())) {
    return By.linkText(findBy.linkText());
  }
  if (!"".equals(findBy.name())) {
    return By.name(findBy.name());
  }
  if (!"".equals(findBy.partialLinkText())) {
    return By.partialLinkText(findBy.partialLinkText());
  }
  if (!"".equals(findBy.tagName())) {
    return By.tagName(findBy.tagName());
  }
  if (!"".equals(findBy.xpath())) {
    return By.xpath(findBy.xpath());
  }
  // Fall through
  return null;
}

相关文章