Java Code Examples for org.openqa.selenium.WebElement#submit()

The following examples show how to use org.openqa.selenium.WebElement#submit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseWebDriverContainerTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
protected void doSimpleWebdriverTest(BrowserWebDriverContainer rule) {
    RemoteWebDriver driver = setupDriverFromRule(rule);
    System.out.println("Selenium remote URL is: " + rule.getSeleniumAddress());
    System.out.println("VNC URL is: " + rule.getVncAddress());

    driver.get("http://www.google.com");
    WebElement search = driver.findElement(By.name("q"));
    search.sendKeys("testcontainers");
    search.submit();

    List<WebElement> results = new WebDriverWait(driver, 15)
        .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#search h3")));

    assertTrue("the word 'testcontainers' appears in search results",
        results.stream()
            .anyMatch(el -> el.getText().contains("testcontainers")));
}
 
Example 2
Source File: NewUserSteps.java    From attic-rave with Apache License 2.0 5 votes vote down vote up
@When("I fill in the login form with username \"$username\" password \"$password\"")
public void login(String username, String password) {
    final WebElement loginForm = portal.getLoginForm();
    loginForm.findElement(By.id("usernameField")).sendKeys(username);
    loginForm.findElement(By.id("passwordField")).sendKeys(password);
    loginForm.submit();
}
 
Example 3
Source File: SignupPage.java    From mamute with Apache License 2.0 5 votes vote down vote up
public Home signUp(String name, String email, String password, String passwordConfirmation){
	WebElement signupForm = allByClassName("user-form").get(0);
	signupForm.findElement(By.name("name")).sendKeys(name);
	signupForm.findElement(By.name("email")).sendKeys(email);
	signupForm.findElement(By.name("password")).sendKeys(password);
	signupForm.findElement(By.name("passwordConfirmation")).sendKeys(passwordConfirmation);
	signupForm.submit();
	return new Home(driver);
}
 
Example 4
Source File: AuthorizationCodeTest.java    From ebay-oauth-java-client with Apache License 2.0 5 votes vote down vote up
private String getAuthorizationResponseUrl() throws InterruptedException {
    // Optional, if not specified, WebDriver will search your path for chromedriver.
    System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");

    WebDriver driver = new ChromeDriver();
    OAuth2Api auth2Api = new OAuth2Api();
    String authorizeUrl = auth2Api.generateUserAuthorizationUrl(EXECUTION_ENV, SCOPE_LIST, Optional.of("current-page"));

    driver.get(authorizeUrl);
    Thread.sleep(5000);

    WebElement userId = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.visibilityOf(driver.findElement(By.cssSelector("input[type='text']"))));
    WebElement password = driver.findElement(By.cssSelector("input[type='password']"));

    userId.sendKeys(CRED_USERNAME);
    password.sendKeys(CRED_PASSWORD);
    driver.findElement(By.name("sgnBt")).submit();

    Thread.sleep(5000);

    String url = null;
    if (driver.getCurrentUrl().contains("code=")) {
        printDetailedLog("Code Obtained");
        url = driver.getCurrentUrl();
    } else {
        WebElement agreeBtn = (new WebDriverWait(driver, 10))
                .until(ExpectedConditions.visibilityOf(driver.findElement(By.id("submit"))));

        agreeBtn.submit();
        Thread.sleep(5000);
        url = driver.getCurrentUrl();
    }
    driver.quit();
    return url;
}
 
Example 5
Source File: EditAnswerPage.java    From mamute with Apache License 2.0 5 votes vote down vote up
public QuestionPage edit(String description, String editComment) {
	WebElement editAnswerForm = byClassName("answer-form");
	
	WebElement descriptionInput = editAnswerForm.findElement(By.name("description"));
	descriptionInput.clear();
	descriptionInput.sendKeys(description);
	
	WebElement commentInput = editAnswerForm.findElement(By.name("comment"));
	commentInput.clear();
	commentInput.sendKeys(editComment);
	
	descriptionInput.submit();
	
	return new QuestionPage(driver);
}
 
Example 6
Source File: DebTest.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testDeb2 () throws Exception
{
    final ChannelTester ct = ChannelTester.create ( getWebContext (), "deb2" );
    ct.addAspect ( "deb" );
    ct.addAspect ( "apt" );

    {
        final Set<String> result = ct.upload ( DEB_RESOURCE );
        Assert.assertEquals ( 1, result.size () );
    }
    Assert.assertEquals ( 1, ct.getAllArtifactIds ().size () );

    testUrl ( String.format ( "/apt/%s", ct.getId () ) ); // index page

    getWebContext ().getResolved ( String.format ( "/config/deb/channel/%s/edit", ct.getId () ) );

    final WebElement desc = getWebContext ().findElement ( By.name ( "description" ) );
    desc.sendKeys ( "Test Description" );
    desc.submit ();

    testUrl ( String.format ( "/apt/%s", ct.getId () ), Pattern.compile ( ".*APT Repository \\|.*", Pattern.DOTALL ) ); // index page

    testUrl ( String.format ( "/apt/%s/dists/default/Release", ct.getId () ) );
    testUrl ( String.format ( "/apt/%s/dists/default/main/binary-amd64/Release", ct.getId () ) );
    testUrl ( String.format ( "/apt/%s/dists/default/main/binary-amd64/Packages", ct.getId () ) );
    testUrl ( String.format ( "/apt/%s/dists/default/main/binary-i386/Release", ct.getId () ) );
    testUrl ( String.format ( "/apt/%s/dists/default/main/binary-i386/Packages", ct.getId () ) );
}
 
Example 7
Source File: BasicIT.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 4 votes vote down vote up
private void googleExampleThatSearchesFor(final String searchString) {
    driver.get("http://www.google.com");

    WebElement searchField = driver.findElement(By.name("q"));

    searchField.clear();
    searchField.sendKeys(searchString);

    System.out.println("Page title is: " + driver.getTitle());

    searchField.submit();

    WebDriverWait wait = new WebDriverWait(driver, 10);
    wait.until((ExpectedCondition<Boolean>) d -> d.getTitle().toLowerCase().startsWith(searchString.toLowerCase()));

    System.out.println("Page title is: " + driver.getTitle());
}
 
Example 8
Source File: DefaultAccountSteps.java    From attic-rave with Apache License 2.0 4 votes vote down vote up
@When("I provide my OpenID password \"$openIdPassword\"")
public void loginToOpenIdProvider(String openIdPassword) {
    final WebElement openIdLoginForm = portal.findElement(By.id("password-signin-form"));
    openIdLoginForm.findElement(By.id("password")).sendKeys(openIdPassword);
    openIdLoginForm.submit();
}
 
Example 9
Source File: InstructorFeedbackResultsPage.java    From teammates with GNU General Public License v2.0 4 votes vote down vote up
public void submitEditForm() {
    WebElement submitBtn = browser.driver.findElement(By.id("submitBtn"));
    submitBtn.submit();
}
 
Example 10
Source File: DesignAndOrderTacosBrowserTest.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
private void doLogout() {
  WebElement logoutForm = browser.findElementByCssSelector("form#logoutForm");
  if (logoutForm != null) {
    logoutForm.submit();
  }
}
 
Example 11
Source File: BasicIT.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 4 votes vote down vote up
private void googleExampleThatSearchesFor(final String searchString) throws MalformedURLException {

        WebDriver driver = DriverBase.getDriver();

        driver.get("http://www.google.com");

        WebElement searchField = driver.findElement(By.name("q"));

        searchField.clear();
        searchField.sendKeys(searchString);

        System.out.println("Page title is: " + driver.getTitle());

        searchField.submit();

        WebDriverWait wait = new WebDriverWait(driver, 10, 100);
        wait.until(pageTitleStartsWith(searchString));

        System.out.println("Page title is: " + driver.getTitle());
    }
 
Example 12
Source File: DesignAndOrderTacosBrowserTest.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
private void doLogout() {
  WebElement logoutForm = browser.findElementByCssSelector("form#logoutForm");
  if (logoutForm != null) {
    logoutForm.submit();
  }
}
 
Example 13
Source File: ProfileSteps.java    From attic-rave with Apache License 2.0 4 votes vote down vote up
@When("I submit the edit profile form")
public void submitProfileForm() {
    final WebElement editAccountForm = portal.findElement(By.id("editAccountForm"));
    editAccountForm.submit();
}
 
Example 14
Source File: DesignAndOrderTacosBrowserTest.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
private void doLogout() {
  WebElement logoutForm = browser.findElementByCssSelector("form#logoutForm");
  if (logoutForm != null) {
    logoutForm.submit();
  }
}
 
Example 15
Source File: DesignAndOrderTacosBrowserTest.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
private void doLogout() {
  WebElement logoutForm = browser.findElementByCssSelector("form#logoutForm");
  if (logoutForm != null) {
    logoutForm.submit();
  }
}
 
Example 16
Source File: DesignAndOrderTacosBrowserTest.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
private void doLogout() {
  WebElement logoutForm = browser.findElementByCssSelector("form#logoutForm");
  if (logoutForm != null) {
    logoutForm.submit();
  }
}
 
Example 17
Source File: DesignAndOrderTacosBrowserTest.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
private void doLogout() {
  WebElement logoutForm = browser.findElementByCssSelector("form#logoutForm");
  if (logoutForm != null) {
    logoutForm.submit();
  }
}
 
Example 18
Source File: DesignAndOrderTacosBrowserTest.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
private void doLogout() {
  WebElement logoutForm = browser.findElementByCssSelector("form#logoutForm");
  if (logoutForm != null) {
    logoutForm.submit();
  }
}
 
Example 19
Source File: UserAdminSteps.java    From attic-rave with Apache License 2.0 4 votes vote down vote up
@When("I search for username \"$newuser\"")
public void searchForNewUser(String newuser) {
  WebElement searchForm=portal.findElement(By.id("userSearchForm"));
  searchForm.findElement(By.id("searchTerm")).sendKeys(newuser);
  searchForm.submit();
}
 
Example 20
Source File: ChannelTester.java    From packagedrone with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Upload a file to the channel
 *
 * @param localFileName
 *            the file to upload
 * @return a set of artifact ids which got created by this operation. This
 *         list may be empty or contain one or more artifacts
 */
public Set<String> upload ( final String localFileName )
{
    final Set<String> before = getAllArtifactIds ();

    get ( String.format ( "/channel/%s/add", this.id ) );

    final WebElement link = this.context.findElement ( By.linkText ( "Upload" ) );

    Assert.assertTrue ( link.findElement ( By.xpath ( ".." ) ).getAttribute ( "class" ).contains ( "active" ) );;

    // upload file

    final File input = this.context.getTestFile ( localFileName );

    {
        final WebElement ele = this.context.findElement ( By.id ( "file" ) );
        Assert.assertNotNull ( ele );

        ele.sendKeys ( input.toString () );
        ele.submit ();
    }

    final Set<String> after = getAllArtifactIds ();

    after.removeAll ( before );

    return after;
}