Search in sources :

Example 76 with WebElement

use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.

the class BlackBoxBase method createResearcherUrl.

public static void createResearcherUrl(String url) {
    By addNew = By.xpath("//a[@ng-click='addNewModal()']/span");
    waitForElementVisibility(addNew);
    waitForAngular();
    ngAwareClick(findElement(addNew));
    waitForAngular();
    By urlXpath = By.xpath("(//input[@ng-model='website.url'])[last()]");
    waitForElementVisibility(urlXpath);
    WebElement urlInput = findElement(urlXpath);
    urlInput.sendKeys(url);
    waitForAngular();
}
Also used : By(org.openqa.selenium.By) WebElement(org.openqa.selenium.WebElement)

Example 77 with WebElement

use of org.openqa.selenium.WebElement in project opennms by OpenNMS.

the class IndexPageIT method canRenderSearchBoxes.

/**
     * Can render search boxes.
     *
     * @throws Exception the exception
     */
@Test
public void canRenderSearchBoxes() throws Exception {
    m_driver.get(getBaseUrl() + "opennms/index.jsp");
    // The following input fields will exist on index.jsp, only if includes/search-box.jsp is rendered and processed by AngularJS
    WebElement asyncKsc = findElementByXpath("//input[@ng-model='asyncKsc']");
    Assert.assertNotNull(asyncKsc);
    WebElement asyncNode = findElementByXpath("//input[@ng-model='asyncNode']");
    Assert.assertNotNull(asyncNode);
}
Also used : WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 78 with WebElement

use of org.openqa.selenium.WebElement 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);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 79 with WebElement

use of org.openqa.selenium.WebElement in project opennms by OpenNMS.

the class BSMAdminIT method verifyElementNotPresent.

/**
     * Verifies that the provided element is not present.
     * @param by
     */
private static void verifyElementNotPresent(OpenNMSSeleniumTestCase testCase, final By by) {
    new WebDriverWait(testCase.getDriver(), 5).until(ExpectedConditions.not(new ExpectedCondition<Boolean>() {

        @Nullable
        @Override
        public Boolean apply(@Nullable WebDriver input) {
            try {
                // the default implicit wait timeout is too long, make it shorter
                input.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
                WebElement elementFound = input.findElement(by);
                return elementFound != null;
            } catch (NoSuchElementException ex) {
                return false;
            } finally {
                // set the implicit wait timeout back to the value it has been before
                input.manage().timeouts().implicitlyWait(LOAD_TIMEOUT, TimeUnit.MILLISECONDS);
            }
        }
    }));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) Nullable(javax.annotation.Nullable) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 80 with WebElement

use of org.openqa.selenium.WebElement in project opennms by OpenNMS.

the class SupportPageIT method testSystemReport.

@Test
public void testSystemReport() throws Exception {
    final WebElement generate = m_driver.findElement(By.linkText("Generate a System Report"));
    assertNotNull(generate);
    generate.click();
    // checkboxes are selected by default
    final WebElement allCheckbox = m_driver.findElement(By.cssSelector("input[type=checkbox][name=all]"));
    assertNotNull(allCheckbox);
    assertTrue(m_driver.findElement(By.cssSelector("input[type=checkbox][name=plugins][value=Java]")).isSelected());
    // deselect the "all" checkbox
    allCheckbox.click();
    assertFalse(m_driver.findElement(By.cssSelector("input[type=checkbox][name=plugins][value=Java]")).isSelected());
}
Also used : WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Aggregations

WebElement (org.openqa.selenium.WebElement)520 Test (org.junit.Test)96 WebDriver (org.openqa.selenium.WebDriver)85 PublicAtsApi (com.axway.ats.common.PublicAtsApi)57 Actions (org.openqa.selenium.interactions.Actions)55 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)46 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)40 By (org.openqa.selenium.By)36 URL (java.net.URL)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)34 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)30 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)21 NoSuchElementException (org.openqa.selenium.NoSuchElementException)21 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)19 ArrayList (java.util.ArrayList)18 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)13 Select (org.openqa.selenium.support.ui.Select)13 TimeoutException (org.openqa.selenium.TimeoutException)12 VisualEditorPageObject (com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject)11 List (java.util.List)10