Tabnine Logo
WebElement.clear
Code IndexAdd Tabnine to your IDE (free)

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

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

Refine searchRefine arrow

  • WebElement.sendKeys
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: spring-io/initializr

public void description(String text) {
  this.form.findElement(By.id("description")).clear();
  this.form.findElement(By.id("description")).sendKeys(text);
}
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: spring-io/initializr

public void packageName(String text) {
  this.form.findElement(By.id("packageName")).clear();
  this.form.findElement(By.id("packageName")).sendKeys(text);
}
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: 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

  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: 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

@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

@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 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

@Test
public void idp_initiated_login_invalid_sp() throws Exception {
  //zone1 is IDP (create SP config and user here)
  //zone2 is SP (create IDP config here)
  //start at zone_1_url
  //should land on zone_2_url
  String zoneId1 = "testzone1";
  RestTemplate identityClient = getIdentityClient();
  String adminToken = IntegrationTestUtils.getClientCredentialsToken(baseUrl, "admin", "adminsecret");
  IdentityZoneConfiguration configuration = new IdentityZoneConfiguration();
  IntegrationTestUtils.createZoneOrUpdateSubdomain(identityClient, baseUrl, zoneId1, zoneId1, configuration);
  String testZone1Url = baseUrl.replace("localhost", zoneId1 + ".localhost");
  String email = new RandomValueStringGenerator().generate().toLowerCase() + "@samltesting.org";
  ScimUser idpUser = new ScimUser(null, email, "IDPFirst", "IDPLast");
  idpUser.setPrimaryEmail(email);
  idpUser.setPassword("secr3T");
  IntegrationTestUtils.createUser(adminToken, baseUrl, idpUser, zoneId1);
  webDriver.get(testZone1Url + "/logout.do");
  webDriver.get(testZone1Url + "/login");
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys(email);
  webDriver.findElement(By.name("password")).sendKeys("secr3T");
  webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
  webDriver.get(testZone1Url + "/saml/idp/initiate");
  assertNotNull(webDriver.findElement(By.xpath("//h2[contains(text(), 'Missing sp request parameter')]")));
  webDriver.get(testZone1Url + "/saml/idp/initiate?sp=invalid_entity_id");
  assertNotNull(webDriver.findElement(By.xpath("//h2[contains(text(), 'Invalid sp entity ID')]")));
}
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

webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.name("username")).sendKeys("marissa");
webDriver.findElement(By.name("password")).sendKeys("koala");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
origin: cloudfoundry/uaa

@Test
public void testSimpleSamlLoginWithAddShadowUserOnLoginFalse() throws Exception {
  // Deleting marissa@test.org from simplesamlphp because previous SAML authentications automatically
  // create a UAA user with the email address as the username.
  deleteUser(SAML_ORIGIN, testAccounts.getEmail());
  IdentityProvider provider = IntegrationTestUtils.createIdentityProvider(SAML_ORIGIN, false, baseUrl, serverRunning);
  String clientId = "app-addnew-false"+ new RandomValueStringGenerator().generate();
  String redirectUri = "http://nosuchhostname:0/nosuchendpoint";
  BaseClientDetails client = createClientAndSpecifyProvider(clientId, provider, redirectUri);
  String firstUrl = "/oauth/authorize?"
      + "client_id=" + clientId
      + "&response_type=code"
      + "&redirect_uri=" + URLEncoder.encode(redirectUri, "UTF-8");
  webDriver.get(baseUrl + firstUrl);
  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();
  // We need to verify the last request URL through the performance log because the redirect
  // URI does not exist. When the webDriver follows the non-existent redirect URI it receives a
  // connection refused error so webDriver.getCurrentURL() will remain as the SAML IdP URL.
  List<LogEntry> logEntries = webDriver.manage().logs().get(LogType.PERFORMANCE).getAll();
  List<String> logMessages = logEntries.stream().map(logEntry -> logEntry.getMessage()).collect(Collectors.toList());
  assertThat(logMessages, hasItem(containsString(redirectUri + "?error=access_denied&error_description=SAML+user+does+not+exist.+You+can+correct+this+by+creating+a+shadow+user+for+the+SAML+user.")));
}
origin: cloudfoundry/uaa

@Test
public void testSingleLogoutWithNoLogoutUrlOnIDP() throws Exception {
  SamlIdentityProviderDefinition providerDefinition = createIDPWithNoSLOSConfigured(SAML_ORIGIN);
  IdentityProvider<SamlIdentityProviderDefinition> provider = new IdentityProvider();
  provider.setIdentityZoneId(OriginKeys.UAA);
  provider.setType(OriginKeys.SAML);
  provider.setActive(true);
  provider.setConfig(providerDefinition);
  provider.setOriginKey(providerDefinition.getIdpEntityAlias());
  provider.setName("simplesamlphp for uaa");
  String zoneAdminToken = getZoneAdminToken(baseUrl, serverRunning);
  provider = IntegrationTestUtils.createOrUpdateProvider(zoneAdminToken, baseUrl, 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();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to"));
  webDriver.findElement(By.cssSelector(".dropdown-trigger")).click();
  webDriver.findElement(By.linkText("Sign Out")).click();
  webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to"));
}
origin: cloudfoundry/uaa

webDriver.get(testZone1Url + "/saml/idp/initiate?sp=testzone2.cloudfoundry-saml-login");
webDriver.findElement(By.xpath("//h1[contains(text(), 'Welcome to The Twiglet Zone[" + zoneId1 + "]!')]"));
webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.name("username")).sendKeys(email);
webDriver.findElement(By.name("password")).sendKeys("secr3T");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
origin: cloudfoundry/uaa

try {
  webDriver.findElement(By.xpath("//h1[contains(text(), 'Welcome to The Twiglet Zone[" + idpZoneId + "]!')]"));
  webDriver.findElement(By.name("username")).clear();
  webDriver.findElement(By.name("username")).sendKeys(idpZoneUserEmail);
  webDriver.findElement(By.name("password")).sendKeys("secr3T");
  webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
origin: la-team/light-admin

@Override
public void clear(final WebElement field) {
  field.click();
  field.clear();
  field.sendKeys(Keys.TAB);
}
org.openqa.seleniumWebElementclear

Javadoc

If this element is a text entry element, this will clear the value. Has no effect on other elements. Text entry elements are INPUT and TEXTAREA elements. Note that the events fired by this event may not be as you'd expect. In particular, we don't fire any keyboard or mouse events. If you want to ensure keyboard events are fired, consider using something like #sendKeys(CharSequence...) with the backspace key. To ensure you get a change event, consider following with a call to #sendKeys(CharSequence...)with the tab key.

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
  • sendKeys
    Use this method to simulate typing into an element, which may set its value.
  • getAttribute
    Get the value of the given attribute of the element. Will return the current value, even if this has
  • 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

  • Start an intent from android
  • startActivity (Activity)
  • setContentView (Activity)
  • setScale (BigDecimal)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • JButton (javax.swing)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now