code: public Integer getNumberFor(WebElement element) {
          Integer number = null;
          if ("li".equalsIgnoreCase(element.getTagName())
                  && element.isDisplayed()) {
              int num;
              String ownVal = element.getAttribute("value");
              if (ownVal != null && !"0".equals(ownVal)) {
                  num = toInt(ownVal, 0);
              } else {
                  String start = element.findElement(By.xpath("ancestor::ol")).getAttribute("start");
                  num = toInt(start, 1);
  
                  List<WebElement> allItems = element.findElements(By.xpath("ancestor::ol/li"));
                  int index = allItems.indexOf(element);
                  for (int i = 0; i < index; i++) {
                      WebElement item = allItems.get(i);
                      if (item.isDisplayed()) {
                          num++;
                          String val = item.getAttribute("value");
                          int valNum = toInt(val, num);
                          if (valNum != 0) {
                              num = valNum + 1;
                          }
                      }
                  }
              }
              number = num;
          }
          return number;
      }
docs: Determines number displayed for item in ordered list.
  @param element ordered list item.
  @return number, if one could be determined.