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.torquebox.integration.arquillian.rails3.FormHandlingTest.java

License:Open Source License

@Test
public void testFormOnFirstRender() {
    Options options = driver.manage();//  w w  w.  j  a v  a2 s  . c o  m

    String cookieValue = null;

    driver.get("http://localhost:8080/basic-rails/form_handling");
    assertEquals(1, options.getCookies().size());
    assertNotNull(options.getCookieNamed("JSESSIONID"));
    cookieValue = options.getCookieNamed("JSESSIONID").getValue();
    assertNotNull(cookieValue);

    WebElement form = driver.findElementById("the-form");
    assertNotNull(form);

    WebElement authTokenInput = driver.findElementByXPath("//input[@name='authenticity_token']");
    assertNotNull(authTokenInput);

    String authToken = authTokenInput.getValue();
    assertNotNull(authToken);

    WebElement valueInput = driver.findElementById("the-value");
    assertNotNull(valueInput);
    assertEquals("", valueInput.getValue());

    valueInput.sendKeys("the value I submit");

    form.submit();

    valueInput = driver.findElementById("the-value");
    assertNotNull(valueInput);
    assertEquals("the value I submit is returned", valueInput.getValue());

    authTokenInput = driver.findElementByXPath("//input[@name='authenticity_token']");
    assertNotNull(authTokenInput);

    assertNotNull(authTokenInput.getValue());

    assertEquals(authToken, authTokenInput.getValue());
}

From source file:org.torquebox.integration.arquillian.rails3.FormHandlingTest.java

License:Open Source License

@Test
public void testFlashUploadSessionUrlMatrix() {
    Options options = driver.manage();//from  www .j  a  v a2 s .  c  o m

    String cookieValue = null;

    driver.get("http://localhost:8080/basic-rails/form_handling/upload_file");
    assertEquals(1, options.getCookies().size());
    assertNotNull(options.getCookieNamed("JSESSIONID"));
    cookieValue = options.getCookieNamed("JSESSIONID").getValue();
    assertNotNull(cookieValue);

    WebElement form = driver.findElementById("the-upload-form");
    assertNotNull(form);

    WebElement authTokenInput = driver.findElementByXPath("//input[@name='authenticity_token']");
    assertNotNull(authTokenInput);

    String authToken = authTokenInput.getValue();
    assertNotNull(authToken);

    String action = form.getAttribute("action");

    assertTrue(action.contains(cookieValue));

    WebElement fileInput = driver.findElementById("the-file");

    URL fileUrl = getClass().getResource("data.txt");
    String filePath = fileUrl.getFile();

    fileInput.sendKeys(filePath);

    // CLEAR ALL COOKIES
    options.deleteAllCookies();

    form.submit();

    WebElement data = driver.findElementById("data");

    assertEquals("Just some data. As returned.", data.getText().trim());

    // No cookie should have been set, since session *was* passed.
    assertNull(options.getCookieNamed("JSESSIONID"));
}

From source file:org.uiautomation.ios.selenium.Demo.java

License:Apache License

public static void main3(String[] args) throws Exception {

    DesiredCapabilities safari = IOSCapabilities.ipad("Safari");
    RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), safari);

    driver.get("http://ebay.co.uk");

    ((Rotatable) new Augmenter().augment(driver)).rotate(ScreenOrientation.LANDSCAPE);

    WebElement search = driver.findElement(By.id("srchDv"));
    search.sendKeys("ipod");
    search.submit();

    waitFor(pageTitleToBe(driver, "ipod | eBay Mobile Web"));

    driver.quit();//from  w  w  w. j  a  va2 s .c o m
}

From source file:org.uiautomation.ios.selenium.Demo.java

License:Apache License

public static void main2(String[] args) throws Exception {

    DesiredCapabilities safari = IOSCapabilities.iphone("Safari");
    RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), safari);

    driver.get("http://hp.mobileweb.ebay.co.uk/home");
    WebElement search = driver.findElement(By.id("srchDv"));
    search.sendKeys("ipod");
    search.submit();

    waitFor(pageTitleToBe(driver, "ipod | eBay Mobile Web"));

    driver.quit();/* w  w w  . jav a 2 s  .  com*/
}

From source file:org.uiautomation.ios.selenium.FormHandlingTest.java

License:Apache License

@Test(enabled = false)
public void testShouldBeAbleToUploadTheSameFileTwice() throws IOException {
    File file = File.createTempFile("test", "txt");
    file.deleteOnExit();//  www .j a v a  2 s. com

    driver.get(pages.formPage);
    WebElement uploadElement = driver.findElement(By.id("upload"));
    assertEquals(uploadElement.getAttribute("value"), (""));

    uploadElement.sendKeys(file.getAbsolutePath());
    uploadElement.submit();

    driver.get(pages.formPage);
    uploadElement = driver.findElement(By.id("upload"));
    assertEquals(uploadElement.getAttribute("value"), (""));

    uploadElement.sendKeys(file.getAbsolutePath());
    uploadElement.submit();

    // If we get this far, then we're all good.
}

From source file:org.uiautomation.ios.selenium.FormHandlingTest.java

License:Apache License

@Test(enabled = false)
// @Ignore(value = { ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, SAFARI,
// SELENESE, OPERA_MOBILE }, reason =
// "Untested on all other browsers, fails on chrome, fails on IE.", issues = {
// 3508 })/*from  w  w  w.  j  a  va 2 s  .  c o  m*/
public void handleFormWithJavascriptAction() {
    String url = appServer.whereIs("form_handling_js_submit.html");
    driver.get(url);
    WebElement element = driver.findElement(By.id("theForm"));
    element.submit();
    Alert alert = driver.switchTo().alert();
    String text = alert.getText();
    alert.dismiss();

    assertEquals("Tasty cheese", text);
}

From source file:ru.mystamps.web.tests.page.AbstractPage.java

License:Open Source License

public void logout() {
    // TODO: check than we not authenticated and do nothing

    WebElement logoutButton = getElementByXPath(LOGOUT_BUTTON_LOCATOR);
    logoutButton.submit();

    // return to current page
    open();/*from www  . jav a 2 s .  c o m*/
    // TODO: test for presence link with text "Sign in" to ensure than all right?
}

From source file:ru.stqa.selenium.wait.RepeatableActions.java

License:Apache License

public static RepeatableAction<WebElement, Boolean> performSubmit() {
    return new AbstractRepeatableAction<WebElement, Boolean>() {
        @Override// w  ww .  j av  a  2 s  .co m
        public Boolean apply(WebElement element) {
            element.submit();
            return true;
        }

        @Override
        public boolean shouldIgnoreException(Throwable t) {
            return t instanceof ElementNotVisibleException;
        }
    };
}

From source file:runkoserver.integration.AreaTest.java

@Before
public void userIsLoggedIn() {
    driver.get(LINK_LOCALHOST + LINK_LOGIN);

    WebElement username = driver.findElement(By.name(ATTRIBUTE_USERNAME));
    WebElement password = driver.findElement(By.name(ATTRIBUTE_PASSWORD));

    username.sendKeys(LOGIN_TEST);//from   w w w .  j a v  a  2 s  .  c  o  m
    password.sendKeys(PASSWORD_TEST);
    password.submit();
}

From source file:runkoserver.integration.AreaTest.java

private Area createNewArea(String areaName, String areaVisibility) {
    driver.get(LINK_LOCALHOST + LINK_AREA + LINK_AREA_FORM);

    WebElement name = driver.findElement(By.name(ATTRIBUTE_NAME));
    WebElement publicity = driver.findElement(By.id(areaVisibility));

    String theName = areaName;/*w  w  w  .j a v  a  2  s .  c o  m*/
    name.sendKeys(theName);
    publicity.click();
    publicity.submit();

    return areaService.findAreaByName(theName);
}