use of org.openqa.selenium.support.ui.WebDriverWait in project opennms by OpenNMS.
the class JmxConfigurationGeneratorIT method configureJMXConnection.
protected void configureJMXConnection(final boolean skipDefaultVM) throws Exception {
final long end = System.currentTimeMillis() + LOAD_TIMEOUT;
final WebDriverWait shortWait = new WebDriverWait(m_driver, 10);
final String skipDefaultVMxpath = "//span[@id='skipDefaultVM']/input";
final boolean selected = waitForElement(By.xpath(skipDefaultVMxpath)).isSelected();
LOG.debug("skipDefaultVM selected: {}", selected);
if (selected != skipDefaultVM) {
waitForElement(By.xpath(skipDefaultVMxpath)).click();
}
// configure authentication
final WebElement authenticateElement = waitForElement(By.id("authenticate"));
if (!authenticateElement.isSelected()) {
authenticateElement.findElement(By.tagName("input")).click();
}
/*
* Sometimes, Vaadin just loses input, or focus. Or both! I suspect it's
* because of the way Vaadin handles events and DOM-redraws itself, but...
* ¯\_(ツ)_/¯
*
* To make sure it really really *really* works, there are multiple layers
* of belt-and-suspenders-and-glue-and-staples:
*
* 1. Click first to ensure the field is focused
* 2. Clear the current contents of the field
* 3. Send the text to the field
* 4. Click it *again* because sometimes this wakes up the event handler
* 5. Do it all in a loop that checks for validation errors, because
* *sometimes* even with all that, it will fail to fill in a field...
* In that case, hit escape to clear the error message and start all
* over and try again.
*/
boolean found = false;
do {
setVaadinValue("authenticateUser", "admin");
setVaadinValue("authenticatePassword", "admin");
// go to next page
waitForElement(By.id("next")).click();
try {
setImplicitWait(1, TimeUnit.SECONDS);
found = shortWait.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(final WebDriver driver) {
try {
final WebElement elem = driver.findElement(By.cssSelector("div.v-Notification-error h1"));
LOG.debug("Notification error element: {}", elem);
if (elem != null) {
elem.sendKeys(Keys.ESCAPE);
return false;
}
} catch (final NoSuchElementException | StaleElementReferenceException e) {
LOG.warn("Exception while checking for errors message.", e);
}
try {
final Boolean contains = pageContainsText(MBEANS_VIEW_TREE_WAIT_NAME).apply(driver);
LOG.debug("Page contains '{}'? {}", MBEANS_VIEW_TREE_WAIT_NAME, contains);
return contains;
} catch (final Exception e) {
LOG.warn("Exception while checking for next page.", e);
}
return false;
}
});
} catch (final Exception e) {
LOG.debug("Failed to configure authentication and port.", e);
} finally {
setImplicitWait();
}
} while (System.currentTimeMillis() < end && !found);
}
use of org.openqa.selenium.support.ui.WebDriverWait in project opennms by OpenNMS.
the class IndexPageIT method verifyStatusMap.
@Test
public void verifyStatusMap() {
// In order to have anything show up, we have to create a node with long/lat information first
// A interface and service which does not exist is used, in order to provoke an alarm beeing sent by opennms
// to have a status >= Warning
// INITIALIZE
LOG.info("Initializing foreign source with no detectors");
String foreignSourceXML = "<foreign-source name=\"" + OpenNMSSeleniumTestCase.REQUISITION_NAME + "\">\n" + "<scan-interval>1d</scan-interval>\n" + "<detectors/>\n" + "<policies/>\n" + "</foreign-source>";
createForeignSource(REQUISITION_NAME, foreignSourceXML);
LOG.info("Initializing node with source with no detectors");
String requisitionXML = "<model-import foreign-source=\"" + OpenNMSSeleniumTestCase.REQUISITION_NAME + "\">" + " <node foreign-id=\"tests\" node-label=\"192.0.2.1\">" + " <interface ip-addr=\"192.0.2.1\" status=\"1\" snmp-primary=\"N\">" + " <monitored-service service-name=\"ICMP\"/>" + " </interface>" + " <asset name=\"longitude\" value=\"-0.075949\"/>" + " <asset name=\"latitude\" value=\"51.508112\"/>" + " </node>" + "</model-import>";
createRequisition(REQUISITION_NAME, requisitionXML, 1);
// try every 5 seconds, for 120 seconds, until the service on 127.0.0.2 has been detected as "down", or fail afterwards
try {
setImplicitWait(5, TimeUnit.SECONDS);
new WebDriverWait(m_driver, 120).until(new Predicate<WebDriver>() {
@Override
public boolean apply(@Nullable WebDriver input) {
// refresh page
input.get(getBaseUrl() + "opennms/index.jsp");
// Wait until we have markers
List<WebElement> markerElements = input.findElements(By.xpath("//*[contains(@class, 'leaflet-marker-icon')]"));
return !markerElements.isEmpty();
}
});
} finally {
setImplicitWait();
}
}
use of org.openqa.selenium.support.ui.WebDriverWait in project ORCID-Source by ORCID.
the class SigninTest method dismissVerifyEmailModal.
public static void dismissVerifyEmailModal(WebDriver webDriver) {
WebDriverWait wait = new WebDriverWait(webDriver, 10);
List<WebElement> weList = webDriver.findElements(By.xpath("//div[@ng-controller='VerifyEmailCtrl']"));
if (weList.size() > 0) {
// we need to wait for the color box to appear
wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[@ng-controller='VerifyEmailCtrl' and @orcid-loading='false']")));
((JavascriptExecutor) webDriver).executeScript("$.colorbox.close();");
colorBoxIsClosed(wait);
}
}
use of org.openqa.selenium.support.ui.WebDriverWait in project ORCID-Source by ORCID.
the class AddWorksTest method addThreeSimple.
@Test
public void addThreeSimple() {
String workNameA = ADD_WORK_TEST + "_" + _A;
String workNameB = ADD_WORK_TEST + "_" + _B;
String workNameC = ADD_WORK_TEST + "_" + _C;
WebDriverWait wait = new WebDriverWait(webDriver, 10);
waitWorksLoaded(wait, webDriver);
// clean up any from previous test
deleteAllByWorkName(workNameA, webDriver);
deleteAllByWorkName(workNameB, webDriver);
deleteAllByWorkName(workNameC, webDriver);
// Test actually begins
addSimple(workNameA, webDriver);
addSimple(workNameB, webDriver);
addSimple(workNameC, webDriver);
assertEquals(1, webDriver.findElements(byWorkTitle(workNameA)).size());
assertEquals(1, webDriver.findElements(byWorkTitle(workNameB)).size());
assertEquals(1, webDriver.findElements(byWorkTitle(workNameC)).size());
// clean up any from previous test
deleteAllByWorkName(workNameA, webDriver);
deleteAllByWorkName(workNameB, webDriver);
deleteAllByWorkName(workNameC, webDriver);
}
use of org.openqa.selenium.support.ui.WebDriverWait in project ORCID-Source by ORCID.
the class AddWorksTest method deleteAllByWorkName.
public static void deleteAllByWorkName(String workName, WebDriver webDriver) {
WebDriverWait wait = new WebDriverWait(webDriver, 10);
waitWorksLoaded(wait, webDriver);
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
List<WebElement> wList = webDriver.findElements(By.xpath("//*[@orcid-put-code and descendant::span[text() = '" + workName + "']]"));
if (wList.size() > 0)
for (WebElement we : wList) {
String putCode = we.getAttribute("orcid-put-code");
putCode = "" + putCode;
String deleteJsStr = "angular.element(document.body).injector().get('worksSrvc').deleteWork('" + putCode + "');";
((JavascriptExecutor) webDriver).executeScript(deleteJsStr);
waitWorksLoaded(wait, webDriver);
}
BBBUtil.extremeWaitFor(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(byWorkTitle(workName))), webDriver);
assertTrue(0 == webDriver.findElements(byWorkTitle(workName)).size());
}
Aggregations