List of usage examples for org.openqa.selenium.remote RemoteWebDriver findElement
@Override
public WebElement findElement(By by)
From source file:com.watchrabbit.crawler.executor.strategy.PageContentWordsStrategy.java
License:Apache License
@Override public List<String> generateKeywords(CrawlForm form, RemoteWebDriver driver) { String pageText = driver.findElement(By.tagName("body")).getText(); List<String> words = Stream.of(pageText.split("\\s")) .map(wordWithPunctation -> wordWithPunctation.replaceAll("[^a-zA-Z]", "")) .map(mixCaseWord -> mixCaseWord.toLowerCase()) .filter(anyWord -> anyWord.length() > 3 && anyWord.length() < 20).collect(toList()); Random random = new Random(); return Stream.generate(() -> random.nextInt() % words.size()) .map(index -> index < 0 ? index + words.size() : index).map(index -> words.get(index)).distinct() .limit(maximumKeywords).collect(toList()); }
From source file:com.watchrabbit.scanner.supervisor.strategy.ContentBasedValueGenerator.java
License:Apache License
@Override public List<String> prepareValues(RemoteWebDriver driver) { String pageText = driver.findElement(By.tagName("body")).getText(); return Stream.of(pageText.split("\\s")) .map(wordWithPunctation -> wordWithPunctation.replaceAll("[^a-zA-Z]", "")) .map(mixCaseWord -> mixCaseWord.toLowerCase()) .filter(anyWord -> anyWord.length() > 3 && anyWord.length() < 20).distinct().collect(toList()); }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void click(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))).click(); }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void type(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))) .sendKeys(params.get("text")); }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void assertText(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String targetText = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))) .getText();//from ww w . j a v a2 s .c om if (!targetText.equals(params.get("text"))) state.setAborted(); }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void assertValue(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String value = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))) .getAttribute("value"); if (!value.equals(params.get("value"))) state.setAborted();// w ww .j a va2s .c o m }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void assertTable(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String[] path = params.get("target").split("\\."); WebElement webElement = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(path[0])) .findElements(By.tagName("tr")).get(Integer.parseInt(path[1])).findElements(By.tagName("td")) .get(Integer.parseInt(path[2])); String text = webElement.getText(); if (!text.equals(params.get("value"))) state.setAborted();/*from w w w . ja v a 2s . c o m*/ }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void assertElementPresent(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { try {/* w ww. ja v a 2 s. com*/ WebElement webElement = remoteWebDriver .findElement(CommandMappings.detectTargetMethod(params.get("target"))); } catch (org.openqa.selenium.NoSuchElementException ex) { state.setAborted(); } }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void verifyText(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String targetText = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))) .getText();//from w w w .j av a2 s . c om if (!targetText.equals(params.get("text"))) state.setFailed(); }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void verifyValue(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String value = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))) .getAttribute("value"); if (!value.equals(params.get("value"))) state.setFailed();// w w w . j a v a 2 s . co m }