use of org.openqa.selenium.TimeoutException in project cerberus-source by cerberustesting.
the class WebDriverService method doSeleniumActionWaitVanish.
@Override
public MessageEvent doSeleniumActionWaitVanish(Session session, Identifier identifier) {
MessageEvent message;
try {
WebDriverWait wait = new WebDriverWait(session.getDriver(), TIMEOUT_WEBELEMENT);
wait.until(ExpectedConditions.invisibilityOfElementLocated(this.getBy(identifier)));
message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_WAITVANISH_ELEMENT);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
return message;
} catch (TimeoutException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_WAIT_NO_SUCH_ELEMENT);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
LOG.debug(exception.toString());
return message;
}
}
use of org.openqa.selenium.TimeoutException in project cerberus-source by cerberustesting.
the class WebDriverService method doSeleniumActionRightClick.
@Override
public MessageEvent doSeleniumActionRightClick(Session session, Identifier identifier) {
MessageEvent message;
try {
AnswerItem answer = this.getSeleniumElement(session, identifier, true, true);
if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
WebElement webElement = (WebElement) answer.getItem();
if (webElement != null) {
Actions actions = new Actions(session.getDriver());
actions.contextClick(webElement);
actions.build().perform();
message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_RIGHTCLICK);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
return message;
}
}
return answer.getResultMessage();
} catch (NoSuchElementException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_RIGHTCLICK_NO_SUCH_ELEMENT);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
LOG.debug(exception.toString());
return message;
} catch (TimeoutException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TIMEOUT);
message.setDescription(message.getDescription().replace("%TIMEOUT%", String.valueOf(session.getCerberus_selenium_wait_element())));
LOG.warn(exception.toString());
return message;
} catch (WebDriverException exception) {
LOG.warn(exception.toString());
return parseWebDriverException(exception);
}
}
use of org.openqa.selenium.TimeoutException in project cerberus-source by cerberustesting.
the class AppiumService method getElement.
private WebElement getElement(Session session, Identifier identifier, boolean visible, boolean clickable) {
AppiumDriver driver = session.getAppiumDriver();
By locator = this.getBy(identifier);
LOG.debug("Waiting for Element : " + identifier.getIdentifier() + "=" + identifier.getLocator());
try {
WebDriverWait wait = new WebDriverWait(driver, TimeUnit.MILLISECONDS.toSeconds(session.getCerberus_appium_wait_element()));
if (visible) {
if (clickable) {
wait.until(ExpectedConditions.elementToBeClickable(locator));
} else {
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
}
} else {
wait.until(ExpectedConditions.presenceOfElementLocated(locator));
}
} catch (TimeoutException exception) {
LOG.fatal("Exception waiting for element :" + exception.toString());
throw new NoSuchElementException(identifier.getIdentifier() + "=" + identifier.getLocator());
}
LOG.debug("Finding Element : " + identifier.getIdentifier() + "=" + identifier.getLocator());
return driver.findElement(locator);
}
use of org.openqa.selenium.TimeoutException 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;
try {
element = webDriverWait().until(new ExpectedCondition<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;
}
use of org.openqa.selenium.TimeoutException in project devonfw-testing by devonfw.
the class DriverExtention method waitForPageLoaded.
public void waitForPageLoaded() throws BFElementNotFoundException {
long startTime = System.currentTimeMillis();
final String jsVariable = "return document.readyState";
ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
return ((JavascriptExecutor) driver).executeScript(jsVariable).equals("complete");
}
};
int progressBarWaitTimer = BasePage.PROGRESSBARWAITTIMER;
WebDriverWait wait = webDriverWait(progressBarWaitTimer);
try {
wait.until(expectation);
} catch (TimeoutException | NoSuchElementException e) {
boolean isTimeout = true;
throw new BFElementNotFoundException(By.cssSelector(jsVariable), isTimeout, progressBarWaitTimer);
}
BFLogger.logTime(startTime, "waitForPageLoaded");
}
Aggregations