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:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public void submit(String buttonName, String buttonValue) {
    WebElement e = getWebElementByXPath(
            "//input[(@type='submit' or @type='image') and (@name=" + escapeQuotes(buttonName) + " or @id="
                    + escapeQuotes(buttonName) + ") and @value=" + escapeQuotes(buttonValue) + "]",
            true, true);/* w  w  w .j a va 2  s .  com*/
    if (e == null) {
        e = getWebElementByXPath(
                "//button[@type='submit' and (@name=" + escapeQuotes(buttonName) + " or @id="
                        + escapeQuotes(buttonName) + ") and @value=" + escapeQuotes(buttonValue) + "]",
                true, true);
    }
    e.submit();
    throwFailingHttpStatusCodeExceptionIfNecessary(getServerResponseCode(), driver.getCurrentUrl());
}

From source file:ohtu.Tester2.java

public static void main(String[] args) {
    WebDriver driver = new HtmlUnitDriver();
    driver.get("http://localhost:8090");
    WebElement element = driver.findElement(By.linkText("register new user"));
    element.click();/*from  w w w.j a  va  2  s. c  o  m*/

    element = driver.findElement(By.name("username"));
    element.sendKeys("asdfasdf");
    element = driver.findElement(By.name("password"));
    element.sendKeys("asdf1234");
    element = driver.findElement(By.name("passwordConfirmation"));
    element.sendKeys("asdf1234");
    element = driver.findElement(By.name("add"));
    element.submit();

    System.out.println(driver.getPageSource().contains("Welcome to Ohtu App!"));
}

From source file:org.apache.camel.web.htmlunit.pages.EndpointsPage.java

License:Apache License

public void createEndpoint(String uri) {
    WebElement form = getCreateEndpointForm();
    form.findElement(name("uri")).sendKeys(uri);
    form.submit();
}

From source file:org.apache.camel.web.htmlunit.pages.SendMessagePage.java

License:Apache License

public void sendMessage(String data) {
    WebElement form = getSendMessage();
    form.findElement(name("body")).sendKeys(data);
    form.submit();
}

From source file:org.apache.geode.tools.pulse.tests.PulseAbstractTest.java

License:Apache License

public static void setUpServer(String username, String password, String jsonAuthFile) throws Exception {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

    jmxPropertiesFile = classLoader.getResource("test.properties").getPath();
    path = getPulseWarPath();//from   w w  w . j a va 2 s. c o m
    server = Server.createServer(9999, jmxPropertiesFile, jsonAuthFile);

    String host = "localhost";
    int port = 8080;
    String context = "/pulse";

    jetty = JettyHelper.initJetty(host, port, new SSLConfig());
    JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
    jetty.start();

    pulseURL = "http://" + host + ":" + port + context;

    Awaitility.await().until(() -> jetty.isStarted());

    driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    driver.get(pulseURL);
    WebElement userNameElement = driver.findElement(By.id("user_name"));
    WebElement passwordElement = driver.findElement(By.id("user_password"));
    userNameElement.sendKeys(username);
    passwordElement.sendKeys(password);
    passwordElement.submit();

    Thread.sleep(3000);
    WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10)).until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver d) {
            return d.findElement(By.id("userName"));
        }
    });
    assertNotNull(userNameOnPulsePage);
    driver.navigate().refresh();
    Thread.sleep(7000);
}

From source file:org.apache.geode.tools.pulse.tests.rules.WebDriverRule.java

License:Apache License

private void login() {
    WebElement userNameElement = waitForElementById("user_name", 60);
    WebElement passwordElement = waitForElementById("user_password");
    userNameElement.sendKeys(username);//w  w  w  .  j a v  a  2s .  c  om
    passwordElement.sendKeys(password);
    passwordElement.submit();

    driver.get(getPulseURL() + "clusterDetail.html");
    WebElement userNameOnPulsePage = (new WebDriverWait(driver, 30)).until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver d) {
            return d.findElement(By.id("userName"));
        }
    });
    assertNotNull(userNameOnPulsePage);
}

From source file:org.apache.portals.pluto.test.utilities.SimpleTestDriver.java

License:Apache License

/**
 * Called to login to the portal if necessary.
 *///from  w w w . j  a  v  a2  s  . c om
protected static void login() {

    driver.get(loginUrl);

    List<WebElement> uels = driver.findElements(By.id(usernameId));
    List<WebElement> pwels = driver.findElements(By.id(passwordId));

    // If there is no login or password fields, don't need to login.
    if (!uels.isEmpty() && !pwels.isEmpty()) {

        System.out.println("login: found userid and password fields");
        WebElement userEl = uels.get(0);
        WebElement pwEl = pwels.get(0);

        // perform login
        userEl.clear();
        userEl.sendKeys(username);
        pwEl.clear();
        pwEl.sendKeys(password);
        pwEl.submit();

    }
}

From source file:org.apache.rave.integrationtests.steps.ProfileSteps.java

License:Apache License

@When("I submit the edit profile form")
public void submitProfileForm() {
    final WebElement editAccountForm = portal.findElement(By.id("editAccountForm"));
    editAccountForm.submit();
}

From source file:org.arquillian.drone.browserstack.extension.webdriver.BrowserStackWebDriverTestCase.java

License:Apache License

private void runTest(WebDriver driver) {
    driver.get("http://www.google.com/");
    WebDriverUtil.checkElementIsPresent(driver, QUERY_FIELD, "The query field should be present");

    WebElement queryElement = driver.findElement(QUERY_FIELD);
    queryElement.sendKeys("browserstack");
    queryElement.submit();

    WebDriverUtil.checkElementContent(driver, SEARCH_RESULTS, "BrowserStack",
            "The search result should contain a string \"BrowserStack\"");
}

From source file:org.arquillian.drone.saucelabs.extension.webdriver.SauceLabsWebDriverTestCase.java

License:Apache License

private void runTest(WebDriver driver) {
    driver.get("http://www.google.com/");
    WebDriverUtil.checkElementIsPresent(driver, QUERY_FIELD, "The query field should be present");

    WebElement queryElement = driver.findElement(QUERY_FIELD);
    queryElement.sendKeys("saucelabs");
    queryElement.submit();

    WebDriverUtil.checkElementContent(driver, SEARCH_RESULTS, "Sauce Labs",
            "The search result should contain a string \"Sauce Labs\"");
}