public void fetchElementsFromPage(String page, int level) { String[] levelTags = getLevelTags(level); if (level == 3) { try { String[] textArray = _driver.findElementByCssSelector("div.main.panel").getText().split("[ \t\\x0B\f\r]+"); int iLen = textArray.length; int iMod = iLen / 100; for (int i = 0; i <= iMod; i++) { String text = ""; if (i == iMod) text = join(textArray, (i * 100), iLen - 1); else text = join(textArray, (i * 100), (i * 100) + 99); _elastic.createIndex(page, "Panel", level, text); } } catch (ElementNotFoundException elemNotFound) { elemNotFound.printStackTrace(); } catch (StaleElementReferenceException staleException) { staleException.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return; } for (String tagName : levelTags) { List<WebElement> elements = _driver.findElementsByTagName(tagName); for (WebElement element : elements) { try { _elastic.createIndex(page, tagName, level, element.getText().trim()); } catch (StaleElementReferenceException staleException) { staleException.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } }
public String getTitle() { return _driver.getTitle(); }
public void navigate(String url) { _driver.navigate().to(url); }