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:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler3.java

License:Apache License

public void processDriver(WebDriver driver) {
    try {//from w  w  w  .  ja va 2  s  .com
        WebElement element = driver.findElement(By.name("login"));

        element.sendKeys(USERNAME);

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys(PASSWORD);

        WebElement remember = driver.findElement(By.name("remember"));
        remember.click();

        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();

        // Check the title of the page
        //System.out.println("Page title is: " + driver.getTitle());

        // Wait for the page to load, timeout after 10 seconds
        (new WebDriverWait(driver, 5)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver driver) {
                JavascriptExecutor js = (JavascriptExecutor) driver;
                return (Boolean) js.executeScript("return jQuery.active == 0");
            }
        });
        //System.out.println("Page title is: " + driver.getTitle());

    } catch (Exception e) {
        System.out.println(e.toString());
    }
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler35.java

License:Apache License

public void processDriver(WebDriver driver) {

    String cur = driver.getCurrentUrl();
    if (cur.contains("/members/") || cur.contains("slickguns.com/alerts/")) {
        Configuration conf = NutchConfiguration.create();
        new WebDriverWait(driver, conf.getLong("libselenium.page.load.delay", 3)); // Wait for the page to load
        try {//from  w w w. j  av a2  s .c om
            WebElement uname = driver.findElement(By.cssSelector("input[type=\"text\"]")); // handling multiple text boxes not needed for these pages

            WebElement remember = driver.findElement(By.cssSelector("input[type=\"checkbox\"]"));
            WebElement pwd = driver.findElement(By.cssSelector("input[type=\"password\"]"));
            uname.sendKeys("team35csci572@outlook.com"); // login info for all 403s

            pwd.sendKeys("qwer1234");
            remember.click(); // Check Remember Me option :)

            pwd.submit();
        } catch (Exception e) {
        }
        driver.navigate().refresh();
        //        new WebDriverWait(driver, 5)) // wait for click and any ending client process to compete execution (we are being generous here)

    }
    driver.close();
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler38.java

License:Apache License

public boolean shouldProcessURL(String URL) {
    System.out.print("============SELENIUM=================");

    WebDriver driver = new FirefoxDriver();

    // And now use this to visit Google
    driver.get(URL);/*  w w  w . j  a  va 2s .c  om*/

    try {
        if ((URL == "https://store.kimberamerica.com/customer/account/login")
                || (URL == "https://palmettostatearmory.com/index.php/customer/account/login/")
                || (URL == "https://www.osagecountyguns.com/customer/account/login/")
                || (URL == "https://www.sogknives.com/customer/account/login/")
                || (URL == "https://www.budsgunshop.com/catalog/login.php")) {
            System.out.println(
                    "***************************login page***********************************************8");
            WebElement email_element = driver.findElement(By.id("email"));
            email_element.sendKeys("las567vegas@gmail.com");
            WebElement pass_element = driver.findElement(By.id("pass"));
            pass_element.sendKeys("lasvegas");
            WebElement submit_element = driver.findElement(By.id("send2"));
            submit_element.submit();
        }

        else if (URL.contains("page")) {
            System.out.println(
                    "************************pagination page***********************************************8");
            if (URL.contains("http://www.shooting.org/"))
                driver.findElement(By.xpath("//a[@rel='next']"));

            else if (URL.contains("https://www.alphacatarmory.com/"))
                driver.findElement(By.className("next"));

            else if (URL.contains("http://www.budsgunshop.com/catalog/"))
                driver.findElement(By.xpath("//a[@class='pageResults' and  @title=' Next Page ']"));
        }
    } catch (Exception e) {
        System.out.println("In exception!!!");

    }
    return true;
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.misc.MiscHandlerUK2.java

License:Apache License

public void processDriver(WebDriver driver) {
    try {//from  ww w  . j  a  v  a 2s.c o  m
        WebElement login = driver.findElement(By.id("radio1"));
        login.click();
        login.submit();
    } catch (Exception e) {
        LOG.info(StringUtils.stringifyException(e));
    }
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.Pagination.PaginationHandlerUK1.java

License:Apache License

public void doLogin(WebDriver driver, String username, String password, String usernameId, String passId,
        String submitId, boolean usernameByName, boolean passByName, boolean submitByName, boolean isClick) {
    System.out.println("Performing web page login");

    try {//from  w  w  w .j  a  v a 2 s  . co m
        //Find the email field
        WebElement username_element = null;

        if (!usernameByName)
            username_element = driver.findElement(By.id(usernameId));
        else
            username_element = driver.findElement(By.name(usernameId));

        username_element.sendKeys(username);

        //Find the password field
        WebElement pass_element = null;

        if (!passByName)
            pass_element = driver.findElement(By.id(passId));
        else
            pass_element = driver.findElement(By.name(passId));

        pass_element.sendKeys(password);

        //Find the submit button
        WebElement submit_element = null;

        if (!submitByName)
            submit_element = driver.findElement(By.id(submitId));
        else
            submit_element = driver.findElement(By.name(submitId));

        if (isClick)
            submit_element.click();
        else
            submit_element.submit();

    } catch (Exception ex) {
        System.out.println("Selinium Login error" + ex.getMessage());
    }

}

From source file:io.fabric8.selenium.FormFacade.java

License:Apache License

public void submit() {
    getFacade().until("Form inputs: " + inputValues, new ExpectedCondition<Boolean>() {
        @Override/*from w ww  . j  a v a 2 s  . c  o m*/
        public Boolean apply(WebDriver driver) {
            logWait("" + inputValues + " on " + driver.getCurrentUrl());
            WebElement submitElement = null;
            for (InputValue inputValue : inputValues) {
                submitElement = inputValue.doInput();
                if (submitElement == null) {
                    logInfo("Missing " + inputValue + "");
                    return false;
                }
            }
            if (submitBy == null && submitElement == null) {
                fail("No input fields submitted yet");
                return false;
            } else {
                getFacade().sleep(Millis.seconds(5));
                if (submitBy != null) {
                    getFacade().untilIsEnabled(submitBy);
                    submitElement = getFacade().findOptionalElement(submitBy);
                    if (submitElement == null) {
                        logWarn("Could not find submit button " + submitBy + "");
                        return false;
                    } else {
                        if (!submitElement.isDisplayed() || !submitElement.isEnabled()) {
                            logWarn("Submit button " + submitBy + " not enabled and visible");
                            return false;
                        }
                        logInfo("Submitting form: " + inputValues + " on " + submitElement + "");
                        submitElement.click();
                    }
                } else {
                    logInfo("Submitting form: " + inputValues + " on " + submitElement + "");
                    submitElement.submit();
                }
                return true;
            }
        }
    });
}

From source file:io.github.seleniumquery.functions.jquery.forms.SubmitFunction.java

License:Apache License

public static void submit(SeleniumQueryObject seleniumQueryObject) {
    for (WebElement webElement : seleniumQueryObject) {
        try {//from  w w  w .  ja  va2s. c om
            webElement.submit();
        } catch (StaleElementReferenceException e) {
            LOGGER.warn(
                    ".submit() was called on an element that is not present anymore. Ignoring further elements on the matched set. (Maybe the .submit() execution on previous elements changed the page.)");
            LOGGER.debug(".submit() exception follows.", e);
            return;
        }
    }
}

From source file:io.selendroid.demo.mobileweb.MobileWebTest.java

License:Apache License

@Test
public void shouldSearchWithEbay() {
    // And now use this to visit ebay
    driver.get("http://m.ebay.de");

    // Find the text input element by its id
    WebElement element = driver.findElement(By.id("kw"));

    // Enter something to search for
    element.sendKeys("Nexus 5");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());
    driver.quit();//ww w.ja v a  2s.  c  o m
}

From source file:io.selendroid.nativetests.NativeElementInteractionTest.java

License:Apache License

@Test
public void shouldSubmitAnElement() {
    openStartActivity();//from www  . ja v  a2 s. co  m
    WebElement button = driver().findElement(By.id("waitingButtonTest"));
    try {
        button.submit();
        Assert.fail();
    } catch (WebDriverException e) {
        Assert.assertTrue(e.getMessage().contains("Submit is not supported for native elements."));
    }
}

From source file:io.selendroid.tests.SayHelloWebviewTest.java

License:Apache License

@Test
public void assertThatWebviewSaysHello() throws Exception {
    WebElement button = driver().findElement(By.id("buttonStartWebview"));

    button.click();/*from   www  .j a va 2 s.com*/
    WebDriverWait wait = new WebDriverWait(driver(), 10);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Go to home screen")));
    driver().switchTo().window("WEBVIEW");

    WebElement inputField = driver().findElement(By.id("name_input"));
    Assert.assertNotNull(inputField);
    inputField.clear();
    inputField.sendKeys("Dominik");

    WebElement car = driver().findElement(By.name("car"));
    Select preferedCar = new Select(car);
    preferedCar.selectByValue("audi");
    inputField.submit();

    WaitingConditions.pageTitleToBe(driver(), "Hello: Dominik");
}