List of usage examples for org.openqa.selenium By toString
@Override
public String toString()
From source file:org.kuali.rice.testtools.selenium.JiraAwareAftBase.java
License:Educational Community License
/** * {@see #checkForIncidentReport} and {@see JiraAwareFailureUtils#fail}. * * @param by to check for a Jira match/*from w ww . j a va 2 s .c o m*/ * @param message to check for a Jira match and fail with. * @param throwable to check for a Jira match */ protected void jiraAwareFail(By by, String message, Throwable throwable) { jiraAwareFail(by.toString(), message, throwable, this); }
From source file:org.kuali.rice.testtools.selenium.JiraAwareAftBase.java
License:Educational Community License
protected WebElement jiraAwareType(By by, String text, String failureMessage) { try {//from w w w. ja va2 s . c o m return type(by, text); } catch (Throwable t) { JiraAwareFailureUtils.failOnMatchedJira(by.toString(), failureMessage, this); jiraAwareFail(t.getMessage() + " " + by.toString() + " unable to type text '" + text + "' " + failureMessage + " current url " + getDriver().getCurrentUrl() + "\n" + AutomatedFunctionalTestUtils.deLinespace(getDriver().getPageSource())); } return null; }
From source file:org.kuali.rice.testtools.selenium.JiraAwareAftBase.java
License:Educational Community License
protected void jiraAwareWaitAndClick(By by, int waitSeconds, String message, JiraAwareFailable failable) throws InterruptedException { try {// w w w . ja va 2 s. com jiraAwareWaitFor(by, waitSeconds, message, failable); findElement(by).click(); // possible future code of outputting clicked components in a more generic way, but need to look into duplicates, don't delete // WebElement element = findElement(by); // String jgrowl = element.getAttribute("name"); // if (jgrowl == null || "".equals(jgrowl)) { // jgrowl = element.getAttribute("id"); // } // if (jgrowl == null || "".equals(jgrowl)) { // jgrowl = by.toString(); // } // WebDriverUtils.jGrowl(getDriver(), "Click " + jgrowl, false, "Click " + jgrowl); // element.click(); } catch (Throwable t) { failable.jiraAwareFail(by.toString(), message, t); } }
From source file:org.kuali.rice.testtools.selenium.JiraAwareAftBase.java
License:Educational Community License
protected void jiraAwareWaitFor(By by, int waitSeconds, String message, JiraAwareFailable failable) throws InterruptedException { try {//from w w w . j av a2 s . c om WebDriverUtils.waitFor(getDriver(), waitSeconds, by, message); } catch (Throwable t) { jiraAwareFail(by.toString(), message, t, failable); } }
From source file:org.kuali.rice.testtools.selenium.JiraAwareAftBase.java
License:Educational Community License
/** * Uses Selenium's findElements method which does not throw a test exception if not found. * @param by/*from w w w .j av a 2s . c o m*/ * @param optionValue * @throws InterruptedException */ protected void selectOption(By by, String optionValue) throws InterruptedException { WebElement select1 = findElement(by); List<WebElement> options = select1.findElements(By.tagName("option")); String name = select1.getAttribute("name"); if (options == null || options.size() == 0) { jiraAwareFail("No options for select " + select1.toString() + " was looking for value " + optionValue + " using " + by.toString()); } for (WebElement option : options) { if (option.getAttribute("value").equals(optionValue)) { WebDriverUtils.jGrowl(getDriver(), "Select " + option.getText(), false, "Select " + option.getText() + " from " + name); option.click(); break; } } }
From source file:org.kuali.rice.testtools.selenium.JiraAwareAftBase.java
License:Educational Community License
/** * Uses Selenium's findElements method which does not throw a test exception if not found. * @param by//from w ww . j a v a 2 s .co m * @param optionText * @throws InterruptedException */ protected void selectOptionText(By by, String optionText) throws InterruptedException { WebElement select1 = findElement(by); List<WebElement> options = select1.findElements(By.tagName("option")); String name = select1.getAttribute("name"); if (options == null || options.size() == 0) { jiraAwareFail("No options for select " + select1.toString() + " was looking for text " + optionText + " using " + by.toString()); } for (WebElement option : options) { if (option.getText().equals(optionText)) { WebDriverUtils.jGrowl(getDriver(), "Select " + option.getText(), false, "Select " + option.getText() + " from " + name); option.click(); break; } } }
From source file:org.kuali.rice.testtools.selenium.JiraAwareAftBase.java
License:Educational Community License
protected WebElement waitAndType(By by, String text, String message) throws InterruptedException { try {//from w w w . ja v a2s. c om jiraAwareWaitFor(by, message); return type(by, text); } catch (Throwable t) { checkForIncidentReport(by.toString(), message); JiraAwareFailureUtils.failOnMatchedJira(by.toString(), message, this); jiraAwareFail(t.getMessage() + " " + by.toString() + " unable to type text '" + text + "' " + message + " current url " + getDriver().getCurrentUrl() + "\n" + AutomatedFunctionalTestUtils.deLinespace(getDriver().getPageSource())); } return null; }
From source file:org.kuali.rice.testtools.selenium.WebDriverAftBase.java
License:Educational Community License
protected List<WebElement> findElements(By by, WebElement element) { if (element == null) { checkForIncidentReport();/*from www . j a v a 2 s.c o m*/ throw new AssertionError("element to findElements on for " + by.toString() + " is null in class " + this.getClass().toString()); } List<WebElement> found = element.findElements(by); return found; }
From source file:org.kuali.rice.testtools.selenium.WebDriverAftBase.java
License:Educational Community License
protected String[] waitAndGetText(By by) throws InterruptedException { WebDriverUtils.waitFors(driver, WebDriverUtils.configuredImplicityWait(), by, this.getClass().toString()); List<WebElement> found = findElements(by); String[] texts = new String[found.size()]; int i = 0;/* ww w .j a v a2s. com*/ for (WebElement element : found) { texts[i++] = element.getText(); } if (texts.length == 0) { jiraAwareFail(by.toString()); } return texts; }
From source file:org.kuali.rice.testtools.selenium.WebDriverAftBase.java
License:Educational Community License
protected WebElement waitForElementVisibleBy(By by) throws InterruptedException { return waitForElementVisibleBy(by, by.toString() + " NOT visible for class " + this.getClass().getSimpleName()); }