Example usage for org.openqa.selenium WebElement submit

List of usage examples for org.openqa.selenium WebElement submit

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement submit.

Prototype

void submit();

Source Link

Document

If this current element is a form, or an element within a form, then this will be submitted to the remote server.

Usage

From source file:org.orcid.api.t2.integration.T2OrcidOAuthApiAuthorizationCodeIntegrationTest.java

License:Open Source License

private String obtainAuthorizationCode(String orcid, String scopes, String redirectUri)
        throws InterruptedException {
    webDriver.get(String.format("%s/oauth/authorize?client_id=%s&response_type=code&scope=%s&redirect_uri=%s",
            webBaseUrl, orcid, scopes, redirectUri));
    WebElement userId = webDriver.findElement(By.id("userId"));
    userId.sendKeys("michael@bentine.com");
    WebElement password = webDriver.findElement(By.id("password"));
    password.sendKeys("password");
    password.submit();
    (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            if (d.getCurrentUrl().contains("authorize")) {
                WebElement authorizeButton = d.findElement(By.name("authorize"));
                if (authorizeButton != null) {
                    return true;
                }/*www  . jav a 2  s  .c om*/
            }
            return false;
        }
    });
    WebElement authorizeButton = webDriver.findElement(By.name("authorize"));
    Thread.sleep(3000);
    authorizeButton.submit();
    (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            return d.getTitle().equals("ORCID Playground");
        }
    });
    String currentUrl = webDriver.getCurrentUrl();
    Matcher matcher = AUTHORIZATION_CODE_PATTERN.matcher(currentUrl);
    assertTrue(matcher.find());
    String authorizationCode = matcher.group(1);
    assertNotNull(authorizationCode);
    return authorizationCode;
}

From source file:org.richfaces.tests.metamer.ftest.richDataScroller.TestDataScrollerFacets.java

License:Open Source License

private void setStringToFacet(WebElement facet, String text) {
    facet.clear();
    facet.sendKeys(text);
    facet.submit();
}

From source file:org.richfaces.tests.metamer.ftest.richEditor.TestRichEditorWithTyping.java

License:Open Source License

/**
 * Provide common steps needed to verify valueChangeListener. Accepts
 * JQueryLocator for submit button - provide ability to verify JSF submit as
 * well as Ajax submit.//from  w  w w  . j  a v  a2  s .c om
 *
 * @param submitBtn
 */
private void verifyValueChangeListener(WebElement submitBtn, final WebElement listener) {

    typeTextToEditor("text1");
    // and submit typed text
    submitBtn.submit();
    new WebDriverWait(driver, WAIT_TIME).until(TextContains.getInstance().element(page.output).text("text1"));
    typeTextToEditor("text2");
    // and submit typed text
    submitBtn.submit();
    new WebDriverWait(driver, WAIT_TIME).until(new Predicate<WebDriver>() {

        @Override
        public boolean apply(WebDriver webDriver) {
            return listener.getText().contains(format(phaseListenerLogFormat, "text1", "text1text2"))
                    || listener.getText().contains(format(phaseListenerLogFormat, "text1", "text2text1"));
        }
    });
}

From source file:org.rivalry.example.illyriad.IllyriadDataCollector.java

License:Open Source License

/**
 * Login to the service.//  ww  w. j a v  a2 s.c o  m
 * 
 * @param dcSpec Data collector specification.
 * @param username Username.
 * @param password Password.
 */
private void login(final DCSpec dcSpec, final String username, final String password) {
    final long start = System.currentTimeMillis();

    // Visit Illyriad.
    final String url = dcSpec.getUrl();

    if (StringUtils.isEmpty(url)) {
        System.out.println("logging in as " + username);
        getWebDriver().get("http://uk1.illyriad.co.uk/Account/LogOn");

        getWebDriver().findElement(By.name("PlayerName")).sendKeys(username);
        final WebElement passwordElement = getWebDriver().findElement(By.name("Password"));
        passwordElement.sendKeys(password);
        passwordElement.submit();
        waitForPageToLoad("The Herald");

        // Open the advanced resources.
        getWebDriver().findElement(By.id("btnResource")).click();
    } else {
        getWebDriver().get(url);
    }

    final long end = System.currentTimeMillis();
    logTiming("login()", start, end);
}

From source file:org.sample.booking.AuthenticationTestCase.java

License:Apache License

@Test
@InSequence(0)/*from  w  ww  .j  a v  a2 s . c om*/
@RunAsClient
public void login(@ArquillianResource URL deploymentURL) throws Exception {
    URL url = deploymentURL.toURI().resolve("embed/BookingPortlet").toURL();
    driver.get(url.toString());
    WebElement loginForm = driver.findElement(By.className("formLogin"));
    assertNotNull(loginForm);

    loginForm.findElement(By.name("username")).sendKeys("demo");
    loginForm.findElement(By.name("password")).sendKeys("demo");
    loginForm.submit();

    WebElement messageBoard = driver.findElement(By.className("fSuccess"));
    assertNotNull(messageBoard);
    assertEquals("Welcome, Demo User", messageBoard.getText());
}

From source file:org.sample.booking.BookingTestCase.java

License:Apache License

@Test
@InSequence(0)//from w ww. j av a  2 s .  c  om
@RunAsClient
public void login(@ArquillianResource URL deploymentURL) throws Exception {
    URL url = deploymentURL.toURI().resolve("embed/BookingPortlet").toURL();
    driver.get(url.toString());
    WebElement loginForm = driver.findElement(By.className("formLogin"));
    loginForm.findElement(By.name("username")).sendKeys("demo");
    loginForm.findElement(By.name("password")).sendKeys("demo");
    loginForm.submit();

    WebElement messageBoard = driver.findElement(By.className("fSuccess"));
    assertNotNull(messageBoard);
    assertEquals("Welcome, Demo User", messageBoard.getText());

    //refresh page and wait until JavaScript code is loaded
    driver.get(url.toString());
}

From source file:org.sample.booking.RegistrationTestCase.java

License:Apache License

@Test
@InSequence(0)/*from  w  w  w  .j  a v a 2  s  .  c o  m*/
@RunAsClient
public void registerUser(@ArquillianResource URL deploymentURL) throws Exception {
    URL url = deploymentURL.toURI().resolve("embed/BookingPortlet").toURL();
    driver.get(url.toString());
    WebElement registerLink = driver.findElement(By.linkText("Register New User"));
    assertNotNull(registerLink);
    registerLink.click();
    WebElement registerForm = driver.findElement(By.tagName("form"));
    assertNotNull(registerForm);

    registerForm.findElement(By.name("username")).sendKeys("testUser");
    registerForm.findElement(By.name("name")).sendKeys("testUserName");
    registerForm.findElement(By.name("password")).sendKeys("testUserPassword");
    registerForm.findElement(By.name("verifyPassword")).sendKeys("testUserPassword");
    registerForm.submit();

    WebElement messageBoard = driver.findElement(By.className("fSuccess"));
    assertNotNull(messageBoard);
    assertEquals("Welcome, testUserName", messageBoard.getText());
}

From source file:org.slc.sli.selenium.controller.LoginSeleniumITest.java

License:Apache License

@Test
public void testLoginPage() {
    driver.get(loginUrl);/*from w  w w.  j  a  v  a  2 s .c  om*/

    /*
     * Test for invalid username
     */
    WebElement username = driver.findElement(By.name("username"));
    username.sendKeys(testBadUser);
    // Before submission - error message should not be displayed
    WebElement errorMessage = driver.findElement(By.name("errorMessage"));
    assertTrue(errorMessage.getCssValue("display").equalsIgnoreCase("none"));

    WebElement loginForm = driver.findElement(By.name("loginForm"));
    loginForm.submit();
    // After submission - error message should be displayed
    errorMessage = driver.findElement(By.name("errorMessage"));
    assertTrue(errorMessage.getCssValue("display").equalsIgnoreCase("block"));

    /*
     * Test for a valid username
     */
    username = driver.findElement(By.name("username"));
    username.sendKeys(testUser);

    loginForm = driver.findElement(By.name("loginForm"));
    loginForm.submit();
    WebElement body = driver.findElement(By.tagName("body"));
    String bodyText = body.getText();
    assertTrue(bodyText.contains("Select an application"));
    driver.close();
}

From source file:org.specrunner.webdriver.actions.PluginSubmit.java

License:Open Source License

@Override
protected void process(IContext context, IResultSet result, WebDriver client, WebElement element)
        throws PluginException {
    element.submit();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.testeditor.fixture.web.WebDriverFixture.java

License:Open Source License

/**
 * Submits WebElements like forms ore whole websites
 * /*from   w  w  w . ja  v  a2  s.c om*/
 * @param elementLocator Locator for Gui-Widget
 * @param locatorType Type of locator for Gui-Widget
 */
@FixtureMethod
public void submit(String elementLocator, LocatorStrategy locatorType) throws FixtureException {
    WebElement element = getWebElement(elementLocator, locatorType);
    try {
        element.submit();
    } catch (NoSuchElementException e) {
        logPageSource(getPageSource());
        throw new FixtureException("element seems not to be part of a form and cannot be submitted", //
                FixtureException.keyValues("elementLocator", elementLocator, //
                        "locatorType", locatorType.toString(), //
                        "element", element.toString(), //
                        "pageSource", getPageSource()),
                e);
    }
}