List of usage examples for org.openqa.selenium By toString
@Override
public String toString()
From source file:org.kuali.rice.testtools.selenium.WebDriverAftBase.java
License:Educational Community License
protected WebElement waitForElementVisibleBy(By by, String message) throws InterruptedException { driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); boolean failed = false; for (int second = 0;; second++) { if (second >= waitSeconds) failed = true;/*from www . ja v a 2s. c o m*/ try { if (failed || driver.findElement(by).isDisplayed()) break; } catch (Exception e) { } Thread.sleep(1000); } checkForIncidentReport(by.toString()); // after timeout to be sure page is loaded driver.manage().timeouts().implicitlyWait(waitSeconds, TimeUnit.SECONDS); if (failed) { jiraAwareFail("timeout of " + waitSeconds + " seconds waiting for " + by + " " + message + " " + driver.getCurrentUrl()); return null; } return driver.findElements(by).get(0); }
From source file:org.kuali.rice.testtools.selenium.WebDriverAftBase.java
License:Educational Community License
protected void waitIsVisible(By by, String message) throws InterruptedException { for (int second = 0;; second++) { if (second >= waitSeconds) { jiraAwareFail(TIMEOUT_MESSAGE + " " + by.toString() + " " + message); }//from w w w. jav a 2 s. c o m if (isVisible(by)) { break; } Thread.sleep(1000); } if (!isVisible(by)) { jiraAwareFail(by.toString() + " not visiable", message); } }
From source file:org.kuali.rice.testtools.selenium.WebDriverITBase.java
License:Educational Community License
/** * /* w ww .j av a 2 s . c om*/ * * @param by method used for finding the element * @param message user defined message to display */ protected void waitAndClick(By by, String message) throws InterruptedException { waitFor(by, message); try { (driver.findElement(by)).click(); } catch (Exception e) { fail(e.getMessage() + " " + by.toString() + " " + message); } }
From source file:org.neo4j.server.webdriver.WebdriverLibrary.java
License:Open Source License
public void waitForElementToAppear(By by) { waitUntil(elementVisible(by), "Element (" + by.toString() + ") did not appear within a reasonable time."); }
From source file:org.nvonop.selenium.framework.controls.Frame.java
License:Open Source License
private static String getLocatorString(By locator) { String[] locatorArray = locator.toString().split("\\s"); String locatorSubString = locatorArray[1]; LOGGER.log(Level.FINEST, "Parsing locator: " + locator.toString()); LOGGER.log(Level.FINEST, "Locator String: " + locatorArray[1]); return locatorSubString; }
From source file:org.nvonop.selenium.framework.utilities.TestHelper.java
License:Open Source License
/** * This method parses a By object and returns is locator value. * * @param locator//from w w w . j a v a 2 s. co m * @return a string representing the locator value */ public String getLocatorString(By locator) { String[] locatorArray = locator.toString().split("\\s"); String locatorSubString = locatorArray[1]; LOGGER.log(Level.FINEST, "Parsing locator: " + locator.toString()); LOGGER.log(Level.FINEST, "Locator String: " + locatorArray[1]); return locatorSubString; }
From source file:org.openqa.runner.CommandMappingsTest.java
License:Apache License
/** * This test depends on current Selenium Implementation * * @TODO add ByDom , when finish ByDom class *///from ww w . ja v a2s .c o m @Test public void testDetectTargetMethod() { String target; target = "//some/path"; By context = CommandMappings.detectTargetMethod(target); assertEquals("By.xpath: //some/path", context.toString()); target = "xpath=//some/path"; context = CommandMappings.detectTargetMethod(target); assertEquals("By.xpath: //some/path", context.toString()); target = "link=Some-text"; context = CommandMappings.detectTargetMethod(target); assertEquals("By.linkText: Some-text", context.toString()); target = "css=#some-id"; context = CommandMappings.detectTargetMethod(target); assertEquals("By.selector: #some-id", context.toString()); target = "name=some-name"; context = CommandMappings.detectTargetMethod(target); assertEquals("By.name: some-name", context.toString()); target = "id=some-id"; context = CommandMappings.detectTargetMethod(target); assertEquals("By.id: some-id", context.toString()); target = "some target"; context = CommandMappings.detectTargetMethod(target); assertEquals("by id or name \"some target\"", context.toString()); }
From source file:org.powertools.web.WebDriverBrowser.java
License:Open Source License
private By getLocator(Item item) { if (item.mType != ItemType.cLink) { // continue } else if (item.mKeyType == KeyType.cText) { By locator = By.linkText(item.mValue); mRunTime.reportInfo("locator: " + locator.toString()); return locator; } else if (item.mKeyType == KeyType.cPartialText) { By locator = By.partialLinkText(item.mValue); mRunTime.reportInfo("locator: " + locator.toString()); return locator; }//from ww w .jav a 2 s . com return getLocator(item.mKeyType, item.getValue()); }
From source file:org.powertools.web.WebDriverBrowser.java
License:Open Source License
private By getLocator(KeyType keyType, String value) { By locator; switch (keyType) { case cClass://from www.ja v a 2s . c om locator = By.className(value); break; case cCss: locator = By.cssSelector(value); break; case cId: locator = By.id(value); break; case cName: locator = By.name(value); break; case cTag: locator = By.tagName(value); break; case cXpath: locator = By.xpath(value); break; default: throw new ExecutionException("invalid key: " + keyType); } mRunTime.reportInfo("locator: " + locator.toString()); return locator; }
From source file:org.qe4j.web.OpenWebDriver.java
License:Open Source License
/** * @return ApigeeWebElement with additional functionality that is also * visible/* w w w. ja va 2 s. co m*/ */ public WebElement findVisibleElement(By arg0) { List<WebElement> elements = findElements(arg0); for (WebElement element : elements) { if (element.isDisplayed()) { return element; } } if (elements.size() > 0) { throw new NoSuchElementException( "An element was found but was not visible identifiedy by " + arg0.toString()); } return null; }