org.openqa.selenium.NoSuchElementException.getLocalizedMessage()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(100)

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

NoSuchElementException.getLocalizedMessage介绍

暂无

代码示例

代码示例来源:origin: Ardesco/Powder-Monkey

static public HashMap<String, String> getWebElementLocator(WebElement element) {
 HashMap<String, String> locator = new HashMap<String, String>();
 Boolean webElementLocated = true;
 String[] componentParts = null;
 try {
  componentParts = element.toString().split("->");
 } catch (NoSuchElementException e) {
  webElementLocated = false;
  componentParts = e.getLocalizedMessage().split("\\{|\\}")[1].split("\"");
 }
 if (webElementLocated) {
  String part = componentParts[componentParts.length - 1];
  String[] parts = part.substring(0, part.length() - 1).split(":");
  locator.put("By", parts[0]);
  locator.put("Locator", parts[1]);
 } else {
  locator.put("By", componentParts[3]);
  locator.put("Locator", componentParts[7]);
 }
 return locator;
}

代码示例来源:origin: windup/windup

private boolean isDependencyPropertyExists(WebElement traitsElement, String key, String value, String dependencyName)
{
  String id = dependencyName +"-"+key;
  try
  {
    WebElement header = traitsElement.findElement(By.id(id));
    if (header != null && header.getText().endsWith(value))
    {
      return true;
    }
  }
  catch (org.openqa.selenium.NoSuchElementException e) 
  {
    System.err.println("Element not found " + e.getLocalizedMessage());
  }
  return false;
}

代码示例来源:origin: org.jboss.windup.tests/test-util

private boolean isDependencyPropertyExists(WebElement traitsElement, String key, String value, String dependencyName)
{
  String id = dependencyName +"-"+key;
  try
  {
    WebElement header = traitsElement.findElement(By.id(id));
    if (header != null && header.getText().endsWith(value))
    {
      return true;
    }
  }
  catch (org.openqa.selenium.NoSuchElementException e) 
  {
    System.err.println("Element not found " + e.getLocalizedMessage());
  }
  return false;
}

代码示例来源:origin: windup/windup

private boolean isDependencyPathsExists(WebElement traitsElement, String key, final List<String> foundPaths, String dependencyName)
{
  String id = dependencyName + "-"+key;
  try
  {
    List<WebElement> pathElements = traitsElement.findElements(By.xpath("//ul[@id='" + id +"']/li"));
    if ( pathElements.size() != foundPaths.size())
    {
      return false;
    }
    List<String> pathsOnPage = new ArrayList<>();
    for (WebElement webElement : pathElements)
    {
       pathsOnPage.add(webElement.getText());
    }
    
    pathsOnPage.removeAll(foundPaths);
    if (pathsOnPage.isEmpty())
    {
      return true;
    }
  } 
  catch (org.openqa.selenium.NoSuchElementException e) 
  {
    System.err.println("Element not found " + e.getLocalizedMessage());
  }
  return false;
}

代码示例来源:origin: org.jboss.windup.tests/test-util

private boolean isDependencyPathsExists(WebElement traitsElement, String key, final List<String> foundPaths, String dependencyName)
{
  String id = dependencyName + "-"+key;
  try
  {
    List<WebElement> pathElements = traitsElement.findElements(By.xpath("//ul[@id='" + id +"']/li"));
    if ( pathElements.size() != foundPaths.size())
    {
      return false;
    }
    List<String> pathsOnPage = new ArrayList<>();
    for (WebElement webElement : pathElements)
    {
       pathsOnPage.add(webElement.getText());
    }
    
    pathsOnPage.removeAll(foundPaths);
    if (pathsOnPage.isEmpty())
    {
      return true;
    }
  } 
  catch (org.openqa.selenium.NoSuchElementException e) 
  {
    System.err.println("Element not found " + e.getLocalizedMessage());
  }
  return false;
}

代码示例来源:origin: org.jboss.windup.tests/test-util

private boolean isDependencyPropertyURLExists(WebElement traitsElement, String key, String value, String dependencyName)
{
  String id = dependencyName+"-"+key;
  try
  {
    WebElement header = traitsElement.findElement(By.id(id));
    if (header != null)
    {
      WebElement url = traitsElement.findElement(By.partialLinkText(value));
      if (url != null)
      {
        return true;
      }
    }
  }
  catch (org.openqa.selenium.NoSuchElementException e) 
  {
    System.err.println("Element not found " + e.getLocalizedMessage());
  }
  return false;
}

代码示例来源:origin: windup/windup

private boolean isDependencyPropertyURLExists(WebElement traitsElement, String key, String value, String dependencyName)
{
  String id = dependencyName+"-"+key;
  try
  {
    WebElement header = traitsElement.findElement(By.id(id));
    if (header != null)
    {
      WebElement url = traitsElement.findElement(By.partialLinkText(value));
      if (url != null)
      {
        return true;
      }
    }
  }
  catch (org.openqa.selenium.NoSuchElementException e) 
  {
    System.err.println("Element not found " + e.getLocalizedMessage());
  }
  return false;
}

相关文章