本文整理了Java中org.openqa.selenium.By.toString()
方法的一些代码示例,展示了By.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。By.toString()
方法的具体详情如下:
包路径:org.openqa.selenium.By
类名称:By
方法名:toString
暂无
代码示例来源:origin: selenide/selenide
public ElementNotFound(Driver driver, By searchCriteria, Condition expectedCondition) {
this(driver, searchCriteria.toString(), expectedCondition, null);
}
代码示例来源:origin: selenide/selenide
static String shortly(By selector) {
if (selector instanceof By.ByCssSelector) {
return selector.toString()
.replaceFirst("By\\.selector:\\s*(.*)", "$1")
.replaceFirst("By\\.cssSelector:\\s*(.*)", "$1");
}
return selector.toString();
}
代码示例来源:origin: selenide/selenide
public static String selector(By selector) {
return selector.toString()
.replaceFirst("By\\.selector:\\s*", "")
.replaceFirst("By\\.cssSelector:\\s*", "");
}
}
代码示例来源:origin: galenframework/galen
public WebElement findElement(SearchContext searchContext) {
List<WebElement> elements = searchContext.findElements(by);
if (next != null) {
if (index > 0 ) {
if (index <= elements.size()) {
return next.findElement(elements.get(index - 1));
}
} else {
if (elements.size() > 0) {
return next.findElement(elements.get(0));
}
}
} else {
if (index > 0) {
if (index <= elements.size()) {
return elements.get(index - 1);
}
} else {
if (elements.size() > 0) {
return elements.get(0);
}
}
}
throw new NoSuchElementException(by.toString() + " | index " + index);
}
代码示例来源:origin: appium/java-client
@Override public String toString() {
return map.get(currentContent).toString();
}
}
代码示例来源:origin: appium/java-client
@Override
public String toString() {
return by.toString();
}
}
代码示例来源:origin: appium/java-client
@Override public void afterFindBy(By by, WebElement element, WebDriver driver) {
messages.add("WebDriverEventListener: The searching for something using "
+ by.toString() + " has beed finished. "
+ "The root element was "
+ String.valueOf(element));
}
代码示例来源:origin: appium/java-client
@Override public void beforeFindBy(By by, WebElement element, WebDriver driver) {
messages.add("Externally defined listener: Attempt to find something using "
+ by.toString() + ". The root element is "
+ String.valueOf(element));
}
代码示例来源:origin: appium/java-client
@Override public void afterFindBy(By by, WebElement element, WebDriver driver) {
messages.add("Externally defined listener: The searching for something using "
+ by.toString() + " has beed finished. "
+ "The root element was "
+ String.valueOf(element));
}
代码示例来源:origin: appium/java-client
@Override public void beforeFindBy(By by, WebElement element, WebDriver driver) {
messages.add("WebDriverEventListener: Attempt to find something using " + by.toString()
+ ". The root element is "
+ String.valueOf(element));
}
代码示例来源:origin: appium/java-client
@Override public void afterFindBy(By by, WebElement element, WebDriver driver) {
messages.add("The searching for something using " + by.toString() + " has beed finished. "
+ "The root element was "
+ String.valueOf(element));
}
代码示例来源:origin: appium/java-client
@Override public void beforeFindBy(By by, WebElement element, WebDriver driver) {
messages.add("Attempt to find something using " + by.toString() + ". The root element is "
+ String.valueOf(element));
}
代码示例来源:origin: appium/java-client
protected static void checkThatLocatorsAreCreatedCorrectly(DefaultStubWidget single,
List<DefaultStubWidget> multiple, By rootLocator,
By subLocator) {
assertThat(single.toString(), containsString(rootLocator.toString()));
assertThat(multiple.stream().map(DefaultStubWidget::toString).collect(toList()),
contains(containsString(rootLocator.toString()),
containsString(rootLocator.toString())));
assertThat(single.getSubWidget().toString(), containsString(subLocator.toString()));
assertThat(single.getSubWidgets().stream().map(Object::toString).collect(toList()),
contains(containsString(subLocator.toString()),
containsString(subLocator.toString())));
assertThat(multiple.stream().map(abstractWidget -> abstractWidget.getSubWidget().toString()).collect(toList()),
contains(containsString(subLocator.toString()),
containsString(subLocator.toString())));
}
}
代码示例来源:origin: appium/java-client
/**
* Find the element.
*/
public WebElement findElement() {
if (cachedElement != null && shouldCache) {
return cachedElement;
}
By bySearching = getBy(this.by, searchContext);
try {
WebElement result = waitFor(() ->
searchContext.findElement(bySearching));
if (shouldCache) {
cachedElement = result;
}
return result;
} catch (TimeoutException | StaleElementReferenceException e) {
throw new NoSuchElementException(format(exceptionMessageIfElementNotFound, bySearching.toString()), e);
}
}
代码示例来源:origin: qaprosoft/carina
/**
* Find Extended Web Element on page using By starting search from this
* object.
*
* @param by Selenium By locator
* @param timeout to wait
* @return ExtendedWebElement if exists otherwise null.
*/
public ExtendedWebElement findExtendedWebElement(By by, long timeout) {
return findExtendedWebElement(by, by.toString(), timeout);
}
代码示例来源:origin: qaprosoft/carina
/**
* Find Extended Web Element on page using By.
*
* @param by
* Selenium By locator
* @return ExtendedWebElement if exists otherwise null.
*/
public ExtendedWebElement findExtendedWebElement(By by) {
return findExtendedWebElement(by, by.toString(), EXPLICIT_TIMEOUT);
}
代码示例来源:origin: qaprosoft/carina
/**
* Find Extended Web Element on page using By.
*
* @param by
* Selenium By locator
* @param timeout to wait
* @return ExtendedWebElement if exists otherwise null.
*/
public ExtendedWebElement findExtendedWebElement(By by, long timeout) {
return findExtendedWebElement(by, by.toString(), timeout);
}
代码示例来源:origin: qaprosoft/carina
/**
* Find Extended Web Element on page using By starting search from this
* object.
*
* @param by Selenium By locator
* @return ExtendedWebElement if exists otherwise null.
*/
public ExtendedWebElement findExtendedWebElement(By by) {
return findExtendedWebElement(by, by.toString(), EXPLICIT_TIMEOUT);
}
代码示例来源:origin: net.serenity-bdd/serenity-core
@Override
public String toString() {
SmartAnnotations annotations = new SmartAnnotations(field, platform);
By by = annotations.buildBy();
return by.toString();
}
}
代码示例来源:origin: qaprosoft/carina
private WebElement findElement(long timeout) {
if (element != null) {
return element;
}
if (isPresent(timeout)) {
//TODO: investigate maybe searchContext better to use here!
element = getDriver().findElement(by);
} else {
throw new NoSuchElementException("Unable to detect element using By: " + by.toString());
}
return element;
}
内容来源于网络,如有侵权,请联系作者删除!