use of org.openqa.selenium.NoSuchElementException in project carina by qaprosoft.
the class AndroidUtils method scroll.
/**
* Scrolls into view in a container specified by it's instance (index)
* @param scrollToEle - has to be id, text, contentDesc or className
* @param scrollableContainer - ExtendedWebElement type
* @param containerSelectorType - has to be id, text, textContains, textStartsWith, Description, DescriptionContains
* or className
* @param containerInstance - has to an instance number of desired container
* @param eleSelectorType - has to be id, text, textContains, textStartsWith, Description, DescriptionContains
* or className
* @return ExtendedWebElement
* <p>
* example of usage:
* ExtendedWebElement res = AndroidUtils.scroll("News", newsListContainer, AndroidUtils.SelectorType.CLASS_NAME, 1,
* AndroidUtils.SelectorType.TEXT);
*/
public static ExtendedWebElement scroll(String scrollToEle, ExtendedWebElement scrollableContainer, SelectorType containerSelectorType, int containerInstance, SelectorType eleSelectorType) {
ExtendedWebElement el = null;
long startTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
for (int i = 0; i < SCROLL_MAX_SEARCH_SWIPES; i++) {
try {
WebElement ele = DriverPool.getDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(" + getScrollContainerSelector(scrollableContainer, containerSelectorType) + ".instance(" + containerInstance + "))" + ".setMaxSearchSwipes(" + SCROLL_MAX_SEARCH_SWIPES + ")" + ".scrollIntoView(" + getScrollToElementSelector(scrollToEle, eleSelectorType) + ")"));
if (ele.isDisplayed()) {
LOGGER.info("Element found!!!");
el = new ExtendedWebElement(ele, scrollToEle, DriverPool.getDriver());
break;
}
} catch (NoSuchElementException noSuchElement) {
LOGGER.error(String.format("Element %s:%s was NOT found.", eleSelectorType, scrollToEle), noSuchElement);
}
for (int j = 0; j < i; j++) {
checkTimeout(startTime);
MobileBy.AndroidUIAutomator("new UiScrollable(" + getScrollContainerSelector(scrollableContainer, containerSelectorType) + ".instance(" + containerInstance + ")).scrollForward()");
LOGGER.info("Scroller got stuck on a page, scrolling forward to next page of elements..");
}
}
return el;
}
use of org.openqa.selenium.NoSuchElementException in project carina by qaprosoft.
the class AndroidUtils method scroll.
/**
* Scrolls into view in specified container
* @param scrollToEle - has to be id, text, contentDesc or className
* @param scrollableContainer - ExtendedWebElement type
* @param containerSelectorType - container Selector type: has to be id, text, textContains, textStartsWith, Description, DescriptionContains
* or className
* @param eleSelectorType - scrollToEle Selector type: has to be id, text, textContains, textStartsWith, Description, DescriptionContains
* or className
* @return ExtendedWebElement
* <p>
* example of usage:
* ExtendedWebElement res = AndroidUtils.scroll("News", newsListContainer, AndroidUtils.SelectorType.CLASS_NAME,
* AndroidUtils.SelectorType.TEXT);
*/
public static ExtendedWebElement scroll(String scrollToEle, ExtendedWebElement scrollableContainer, SelectorType containerSelectorType, SelectorType eleSelectorType) {
ExtendedWebElement el = null;
long startTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
for (int i = 0; i < SCROLL_MAX_SEARCH_SWIPES; i++) {
try {
WebElement ele = DriverPool.getDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(" + getScrollContainerSelector(scrollableContainer, containerSelectorType) + ")" + ".setMaxSearchSwipes(" + SCROLL_MAX_SEARCH_SWIPES + ")" + ".scrollIntoView(" + getScrollToElementSelector(scrollToEle, eleSelectorType) + ")"));
if (ele.isDisplayed()) {
LOGGER.info("Element found!!!");
el = new ExtendedWebElement(ele, scrollToEle, DriverPool.getDriver());
break;
}
} catch (NoSuchElementException noSuchElement) {
LOGGER.error(String.format("Element %s:%s was NOT found.", eleSelectorType, scrollToEle), noSuchElement);
}
for (int j = 0; j < i; j++) {
checkTimeout(startTime);
MobileBy.AndroidUIAutomator("new UiScrollable(" + getScrollContainerSelector(scrollableContainer, containerSelectorType) + ").scrollForward()");
LOGGER.info("Scroller got stuck on a page, scrolling forward to next page of elements..");
}
}
return el;
}
use of org.openqa.selenium.NoSuchElementException in project devonfw-testing by devonfw.
the class NewChromeDriver method findElement.
/**
* @deprecated As of release 1.0.0, replaced by {@link #findElementDynamic(By)()}
*/
@Deprecated
@Override
public WebElement findElement(By by) throws BFElementNotFoundException {
BaseTest.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
WebElement elementFromDriver = null;
try {
elementFromDriver = super.findElement(by);
} catch (NoSuchElementException e) {
throw new BFElementNotFoundException(by);
}
return new NewRemoteWebElement(elementFromDriver);
}
use of org.openqa.selenium.NoSuchElementException in project devonfw-testing by devonfw.
the class NewInternetExplorerDriver method findElement.
/**
* @deprecated As of release 1.0.0, replaced by {@link #findElementDynamic(By)()}
*/
@Deprecated
@Override
public WebElement findElement(By by) throws BFElementNotFoundException {
BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
WebElement elementFromDriver = null;
try {
elementFromDriver = super.findElement(by);
} catch (NoSuchElementException e) {
throw new BFElementNotFoundException(by);
}
return new NewRemoteWebElement(elementFromDriver);
}
use of org.openqa.selenium.NoSuchElementException in project devonfw-testing by devonfw.
the class DriverExtention method waitForElement.
public WebElement waitForElement(final By by) throws BFElementNotFoundException {
BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
long startTime = System.currentTimeMillis();
WebElement element = null;
FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver);
wait.pollingEvery(250, TimeUnit.MILLISECONDS);
wait.withTimeout(2, TimeUnit.MINUTES);
try {
element = webDriverWait().until(new Function<WebDriver, WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
return driver.findElement(by);
}
});
} catch (TimeoutException | NoSuchElementException e) {
boolean isTimeout = true;
throw new BFElementNotFoundException(by, isTimeout, BasePage.EXPLICITYWAITTIMER);
}
BFLogger.logTime(startTime, "waitForElement()", by.toString());
return element;
}
Aggregations