Codota Logo
WebElement.sendKeys
Code IndexAdd Codota to your IDE (free)

How to use
sendKeys
method
in
org.openqa.selenium.WebElement

Best Java code snippets using org.openqa.selenium.WebElement.sendKeys (Showing top 20 results out of 1,602)

Refine searchRefine arrow

  • WebElement.clear
  • WebElement.click
  • Common ways to obtain WebElement
private void myMethod () {
WebElement w =
  • Codota IconWebDriver driver;By by;driver.findElement(by)
  • Codota IconWebDriver driver;String id;driver.findElement(By.id(id))
  • Codota IconWebDriver driver;driver.findElement(By.tagName("body"))
  • Smart code suggestions by Codota
}
origin: cloudfoundry/uaa

  private void loginThroughDiscovery(String userEmail, String password) {
    webDriver.findElement(By.id("email")).sendKeys(userEmail);
    webDriver.findElement(By.cssSelector(".form-group input[value='Next']")).click();
    webDriver.findElement(By.id("password")).sendKeys(password);
    webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  }
}
origin: selenide/selenide

private void setValueForTextInput(Driver driver, WebElement element, String text) {
 if (text == null || text.isEmpty()) {
  element.clear();
 }
 else if (driver.config().fastSetValue()) {
  String error = setValueByJs(driver, element, text);
  if (error != null) throw new InvalidStateException(driver, error);
  else {
   events.fireEvent(driver, element, "keydown", "keypress", "input", "keyup", "change");
  }
 }
 else {
  element.clear();
  element.sendKeys(text);
 }
}
origin: cloudfoundry/uaa

  private void login(IdentityProvider<SamlIdentityProviderDefinition> provider) {
    webDriver.get(baseUrl + "/login");
    Assert.assertEquals("Cloud Foundry", webDriver.getTitle());
    webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
    webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
    webDriver.findElement(By.name("username")).clear();
    webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName());
    webDriver.findElement(By.name("password")).sendKeys(testAccounts.getPassword());
    webDriver.findElement(By.xpath("//input[@value='Login']")).click();
  }
}
origin: cloudfoundry/uaa

private void testSimpleSamlLogin(String firstUrl, String lookfor, String username, String password) throws Exception {
  IdentityProvider<SamlIdentityProviderDefinition> provider = createIdentityProvider(SAML_ORIGIN);
  webDriver.get(baseUrl + firstUrl);
  Assert.assertEquals("Cloud Foundry", webDriver.getTitle());
  webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
  //takeScreenShot();
  webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys(username);
  webDriver.findElement(By.name("password")).sendKeys(password);
  webDriver.findElement(By.xpath("//input[@value='Login']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString(lookfor));
  IntegrationTestUtils.validateAccountChooserCookie(baseUrl, webDriver);
}
origin: spring-io/initializr

public void bootVersion(String text) {
  this.form.findElement(By.id("bootVersion")).sendKeys(text);
  this.form.click();
}
origin: spring-io/initializr

public void artifactId(String text) {
  this.form.findElement(By.id("artifactId")).clear();
  this.form.findElement(By.id("artifactId")).sendKeys(text);
}
origin: cloudfoundry/uaa

@Test
public void testLoginClientIDPAuthorizationAlreadyLoggedIn() throws Exception {
  webDriver.get(baseUrl + "/logout.do");
  String adminAccessToken = testClient.getOAuthAccessToken("admin", "adminsecret", "client_credentials", "clients.read clients.write clients.secret clients.admin");
  String clientId = UUID.randomUUID().toString();
  BaseClientDetails clientDetails = new BaseClientDetails(clientId, null, "openid", GRANT_TYPE_AUTHORIZATION_CODE, "uaa.none", "http://localhost:8080/login");
  clientDetails.setClientSecret("secret");
  List<String> idps = Arrays.asList("okta-local"); //not authorized for the current IDP
  clientDetails.addAdditionalInformation(ClientConstants.ALLOWED_PROVIDERS, idps);
  testClient.createClient(adminAccessToken, clientDetails);
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName());
  webDriver.findElement(By.name("password")).sendKeys("koala");
  webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  webDriver.get(baseUrl + "/oauth/authorize?client_id=" + clientId + "&redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Flogin&response_type=code&state=8tp0tR");
  assertThat(webDriver.findElement(By.cssSelector("p")).getText(), Matchers.containsString(clientId + " does not support your identity provider. To log into an identity provider supported by the application"));
  webDriver.get(baseUrl + "/logout.do");
}
origin: cloudfoundry/uaa

  private void signIn(String userName, String password) {
    webDriver.findElement(By.name("username")).sendKeys(userName);
    webDriver.findElement(By.name("password")).sendKeys(password);
    webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  }
}
origin: spring-io/initializr

public void groupId(String text) {
  this.form.findElement(By.id("groupId")).clear();
  this.form.findElement(By.id("groupId")).sendKeys(text);
}
origin: cloudfoundry/uaa

@Test
public void testSingleLogout() throws Exception {
  IdentityProvider<SamlIdentityProviderDefinition> provider = createIdentityProvider(SAML_ORIGIN);
  webDriver.get(baseUrl + "/login");
  Assert.assertEquals("Cloud Foundry", webDriver.getTitle());
  webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
  webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName());
  webDriver.findElement(By.name("password")).sendKeys(testAccounts.getPassword());
  webDriver.findElement(By.xpath("//input[@value='Login']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to"));
  logout();
  IntegrationTestUtils.validateAccountChooserCookie(baseUrl, webDriver);
  webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
  webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
}
origin: cloudfoundry/uaa

public void attemptLogin(String username, String password) {
  webDriver.findElement(By.name("username")).sendKeys(username);
  webDriver.findElement(By.name("password")).sendKeys(password);
  webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
}
origin: spring-io/initializr

public void description(String text) {
  this.form.findElement(By.id("description")).clear();
  this.form.findElement(By.id("description")).sendKeys(text);
}
origin: cloudfoundry/uaa

@Test
public void testSamlLoginClientIDPAuthorizationAutomaticRedirect() throws Exception {
  IdentityProvider<SamlIdentityProviderDefinition> provider = createIdentityProvider(SAML_ORIGIN);
  assertEquals(provider.getOriginKey(), provider.getConfig().getIdpEntityAlias());
  List<String> idps = Arrays.asList(provider.getOriginKey());
  webDriver.get(baseUrl + "/logout.do");
  String adminAccessToken = testClient.getOAuthAccessToken("admin", "adminsecret", "client_credentials", "clients.read clients.write clients.secret clients.admin");
  String clientId = UUID.randomUUID().toString();
  BaseClientDetails clientDetails = new BaseClientDetails(clientId, null, "openid", GRANT_TYPE_AUTHORIZATION_CODE, "uaa.none", baseUrl);
  clientDetails.setClientSecret("secret");
  clientDetails.addAdditionalInformation(ClientConstants.ALLOWED_PROVIDERS, idps);
  clientDetails.setAutoApproveScopes(Collections.singleton("true"));
  testClient.createClient(adminAccessToken, clientDetails);
  webDriver.get(baseUrl + "/oauth/authorize?client_id=" + clientId + "&redirect_uri=" + URLEncoder.encode(baseUrl) + "&response_type=code&state=8tp0tR");
  //we should now be in the Simple SAML PHP site
  webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName());
  webDriver.findElement(By.name("password")).sendKeys("koala");
  webDriver.findElement(By.xpath("//input[@value='Login']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to?"));
  webDriver.get(baseUrl + "/logout.do");
}
origin: cloudfoundry/uaa

private String startCreateUserFlow(String secret) {
  String userEmail = "user" + new SecureRandom().nextInt() + "@example.com";
  webDriver.get(baseUrl + "/");
  webDriver.findElement(By.xpath("//*[text()='Create account']")).click();
  assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText());
  webDriver.findElement(By.name("email")).sendKeys(userEmail);
  webDriver.findElement(By.name("password")).sendKeys(secret);
  webDriver.findElement(By.name("password_confirmation")).sendKeys(secret);
  webDriver.findElement(By.xpath("//input[@value='Send activation link']")).click();
  return userEmail;
}
origin: spring-io/initializr

public void packageName(String text) {
  this.form.findElement(By.id("packageName")).clear();
  this.form.findElement(By.id("packageName")).sendKeys(text);
}
origin: cloudfoundry/uaa

private void testLocalSamlIdpLogin(String firstUrl, String lookfor, String username, String password)
 throws Exception {
  SamlIdentityProviderDefinition idpDef = createLocalSamlIdpDefinition(IDP_ENTITY_ID, "uaa");
  @SuppressWarnings("unchecked")
  IdentityProvider<SamlIdentityProviderDefinition> provider = IntegrationTestUtils.createIdentityProvider(
   "Local SAML IdP", true, this.baseUrl, this.serverRunning, idpDef);
  SamlServiceProviderDefinition spDef = createLocalSamlSpDefinition("cloudfoundry-saml-login", "uaa");
  createSamlServiceProvider("Local SAML SP", "cloudfoundry-saml-login", baseUrl, serverRunning, spDef);
  webDriver.get(baseUrl + firstUrl);
  IntegrationTestUtils.takeScreenShot(webDriver);
  assertEquals("Cloud Foundry", webDriver.getTitle());
  webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
  webDriver.findElement(By.xpath("//h1[contains(text(), 'Welcome!')]"));
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys(username);
  webDriver.findElement(By.name("password")).sendKeys(password);
  webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString(lookfor));
  provider.setActive(false);
  IntegrationTestUtils.updateIdentityProvider(this.baseUrl, this.serverRunning, provider);
}
origin: cloudfoundry/uaa

  private void signIn(String userName, String password) {
    webDriver.get(baseUrl + "/logout.do");
    webDriver.get(baseUrl + "/login");
    webDriver.findElement(By.name("username")).sendKeys(userName);
    webDriver.findElement(By.name("password")).sendKeys(password);
    webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
    assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
  }
}
origin: spring-io/initializr

public void name(String text) {
  this.form.findElement(By.id("name")).clear();
  this.form.findElement(By.id("name")).sendKeys(text);
}
origin: cloudfoundry/uaa

@Test
public void acceptInvitation_for_samlUser() throws Exception {
  webDriver.get(baseUrl + "/logout.do");
  BaseClientDetails appClient = IntegrationTestUtils.getClient(scimToken, baseUrl, "app");
  appClient.setScope(Lists.newArrayList("cloud_controller.read", "password.write", "scim.userids", "cloud_controller.write", "openid", "organizations.acme"));
  appClient.setAutoApproveScopes(Lists.newArrayList("openid"));
  IntegrationTestUtils.updateClient(baseUrl, scimToken, appClient);
  String code = createInvitation(testInviteEmail, testInviteEmail, "http://localhost:8080/app/", "simplesamlphp");
  String invitedUserId = IntegrationTestUtils.getUserIdByField(scimToken, baseUrl, "simplesamlphp", "email", testInviteEmail);
  IntegrationTestUtils.createIdentityProvider("simplesamlphp", true, baseUrl, serverRunning);
  webDriver.get(baseUrl + "/invitations/accept?code=" + code);
  webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys("user_only_for_invitations_test");
  webDriver.findElement(By.name("password")).sendKeys("saml");
  WebElement loginButton = webDriver.findElement(By.xpath("//input[@value='Login']"));
  loginButton.click();
  //wait until UAA page has loaded
  webDriver.findElement(By.id("application_authorization"));
  String acceptedUsername = IntegrationTestUtils.getUsernameById(scimToken, baseUrl, invitedUserId);
  //webdriver follows redirects so we should be on the UAA authorization page
  assertEquals("user_only_for_invitations_test", acceptedUsername);
  //external users should default to not being "verified" since we can't determine this
  ScimUser user = IntegrationTestUtils.getUser(scimToken, baseUrl, invitedUserId);
  assertFalse(user.isVerified());
}
origin: cloudfoundry/uaa

private void changePassword(String originalPassword, String newPassword, String confirmPassword) {
  webDriver.findElement(By.xpath("//*[text()='"+userEmail+"']")).click();
  webDriver.findElement(By.linkText("Account Settings")).click();
  webDriver.findElement(By.linkText("Change Password")).click();
  webDriver.findElement(By.name("current_password")).sendKeys(originalPassword);
  webDriver.findElement(By.name("new_password")).sendKeys(newPassword);
  webDriver.findElement(By.name("confirm_password")).sendKeys(confirmPassword);
  webDriver.findElement(By.xpath("//input[@value='Change password']")).click();
}
org.openqa.seleniumWebElementsendKeys

Javadoc

Use this method to simulate typing into an element, which may set its value.

Popular methods of WebElement

  • getText
    Get the visible (i.e. not hidden by CSS) text of this element, including sub-elements.
  • click
    Click this element. If this causes a new page to load, you should discard all references to this ele
  • getAttribute
    Get the value of the given attribute of the element. Will return the current value, even if this has
  • clear
    If this element is a text entry element, this will clear the value. Has no effect on other elements.
  • isDisplayed
    Is this element displayed or not? This method avoids the problem of having to parse an element's "st
  • findElements
    Find all elements within the current context using the given mechanism. When using xpath be aware th
  • isSelected
    Determine whether or not this element is selected or not. This operation only applies to input eleme
  • findElement
    Find the first WebElement using the given method. See the note in #findElements(By) about finding vi
  • getTagName
    Get the tag name of this element. Not the value of the name attribute: will return"input" for the el
  • isEnabled
    Is the element currently enabled or not? This will generally return true for everything but disabled
  • getLocation
    Where on the page is the top left-hand corner of the rendered element?
  • submit
    If this current element is a form, or an element within a form, then this will be submitted to the r
  • getLocation,
  • submit,
  • getSize,
  • getCssValue,
  • getRect,
  • getScreenshotAs,
  • getValue,
  • setSelected,
  • toggle

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • String (java.lang)
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • JFrame (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now