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

The following examples show how to use org.openqa.selenium.WebElement#clear() . 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: Preferences.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Upload private SSH key
 *
 * @param host
 * @param filePath path to file with ssh key
 */
public void uploadPrivateSshKey(String host, String filePath) {
  File file = new File(filePath);
  LOG.info("Absolute path to private SSH key: {}", file.getAbsolutePath());
  seleniumWebDriverHelper.waitAndClick(By.xpath(Locators.SSH_UPLOAD_KEY));
  WebElement hostInput =
      seleniumWebDriverHelper.waitVisibility(
          By.xpath(UploadSSHKey.HOST_INPUT), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
  hostInput.clear();
  hostInput.sendKeys(host);
  seleniumWebDriverHelper.waitAndSendKeysTo(
      By.xpath(UploadSSHKey.FILE_INPUT), file.getAbsolutePath(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
  WaitUtils.sleepQuietly(3);
  seleniumWebDriverHelper.waitAndClick(
      By.xpath(UploadSSHKey.UPLOAD_BUTTON), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
}
 
Example 2
Source File: OpenViduTestAppE2eTest.java    From openvidu with Apache License 2.0 5 votes vote down vote up
void setupChromeWithFakeVideo(Path videoFileLocation) {
	this.user = new MyUser(new ChromeUser("TestUser", 50, videoFileLocation));
	user.getDriver().get(APP_URL);
	WebElement urlInput = user.getDriver().findElement(By.id("openvidu-url"));
	urlInput.clear();
	urlInput.sendKeys(OPENVIDU_URL);
	WebElement secretInput = user.getDriver().findElement(By.id("openvidu-secret"));
	secretInput.clear();
	secretInput.sendKeys(OPENVIDU_SECRET);
	user.getEventManager().startPolling();
}
 
Example 3
Source File: AbstractWebDriverTestClass.java    From Asqatasun with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @param elementName
 * @param elementValue
 */
protected void editWebElement(String elementName, String elementValue) {
    WebElement webElement = getWebElementById(elementName);
    webElement.click();
    webElement.clear();
    webElement.sendKeys(elementValue);
}
 
Example 4
Source File: EventsIT.java    From AisAbnormal with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void navigateToSearchDialogAndSearchEventsByVessel() {
    navigateToSearchDialog();
    WebElement vesselNameCallsignImoField = browser.findElement(id("search-event-vessel"));
    vesselNameCallsignImoField.clear();
    vesselNameCallsignImoField.sendKeys("L");
    WebElement searchByOtherButton = browser.findElement(id("event-search-by-other"));
    searchByOtherButton.click();
    assertNumberOfSearchResults(12);
}
 
Example 5
Source File: DetailsTabUiTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * When filling out the filter input field, the correct rows should be displayed.
 */
@Test
public void shouldDisplayTheFilteredRows() {
    FreeStyleJob job = createFreeStyleJob("findbugs-severities.xml");
    job.addPublisher(IssuesRecorder.class, recorder -> recorder.setToolWithPattern("FindBugs", "**/*.xml"));
    job.save();

    Build build = job.startBuild().waitUntilFinished();
    build.open();

    AnalysisSummary resultPage = new AnalysisSummary(build, "findbugs");
    assertThat(resultPage).isDisplayed();
    AnalysisResult findBugsAnalysisResult = resultPage.openOverallResult();

    assertThat(findBugsAnalysisResult).hasAvailableTabs(Tab.ISSUES);

    findBugsAnalysisResult.openPropertiesTable(Tab.ISSUES);

    WebElement issuesFilterInput = findBugsAnalysisResult.getFilterInputElementByActiveTab();

    issuesFilterInput.sendKeys("CalculateFrame");

    WebElement issuesInfo = findBugsAnalysisResult.getInfoElementByActiveTab();
    waitUntilCondition(issuesInfo, "Showing 1 to 2 of 2 entries (filtered from 12 total entries)");

    issuesFilterInput.clear();

    issuesFilterInput.sendKeys("STYLE");
    waitUntilCondition(issuesInfo, "Showing 1 to 7 of 7 entries (filtered from 12 total entries)");
}
 
Example 6
Source File: TextFieldSteps.java    From colibri-ui with Apache License 2.0 5 votes vote down vote up
@When("очистить \"$fieldName\"")
public void clearField(@Named("$fieldName") String fieldName) {
    WebElement webElement = getWebElementByName(fieldName);
    try {
        webElement.clear();
    } catch (WebDriverException ignored) {
    }
    for (int i = webElement.getText().length(); i > 0; i--) {
        webElement.sendKeys(Keys.BACK_SPACE);
    }
}
 
Example 7
Source File: JTextAreaTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
void getAttributes() throws Throwable {
    driver = new JavaDriver();
    WebElement textArea = driver.findElement(By.cssSelector("text-area"));
    AssertJUnit.assertEquals("true", textArea.getAttribute("editable"));
    textArea.sendKeys("Systems", Keys.SPACE);
    String previousText = textArea.getText();
    textArea.clear();
    textArea.sendKeys("Jalian" + previousText);
}
 
Example 8
Source File: AttributesPage.java    From oxTrust with MIT License 5 votes vote down vote up
public void setValidationRegExp(String regExpValue) {
	WebDriverWait wait = new WebDriverWait(webDriver, 10);
	wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("setValidationRegExpField")));
	WebElement regExText = webDriver.findElement(By.className("setValidationRegExpField"));
	regExText.clear();
	regExText.sendKeys(regExpValue);
}
 
Example 9
Source File: CategoryAdminSteps.java    From attic-rave with Apache License 2.0 5 votes vote down vote up
@When("I change the name of the category to \"$categoryName\"")
public void fillInUpdatedCategory(String categoryName) {
    WebElement form = portal.findElement(By.id("updateCategory"));
    WebElement field = form.findElement(By.id("text"));
    field.clear();
    field.sendKeys(categoryName);
}
 
Example 10
Source File: TopicSubscriptionsPage.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Search topic subscriptions according to the search criteria.
 *
 * @param queueNamePattern string pattern of the topic name (* for all)
 * @param identifierPattern string pattern of the identifier (* for all)
 * @param ownNodeIdIndex index of the node Id in the dropdown the subscriptions belong to
 * @return number of subscriptions listed under search result
 */
public void searchTopicSubscriptions(String queueNamePattern, String identifierPattern, int
        ownNodeIdIndex, boolean isNameExactMatch, boolean isIdentifierExactMatch) {

    WebElement queueNamePatternField = driver.findElement(By.name(UIElementMapper.getInstance()
            .getElement("mb.search.topic.name.pattern.tag.name")));
    queueNamePatternField.clear();
    queueNamePatternField.sendKeys(queueNamePattern);

    WebElement queueIdentifierPatternField = driver.findElement(By.name(UIElementMapper.getInstance()
            .getElement("mb.search.topic.identifier.pattern.tag.name")));
    queueIdentifierPatternField.clear();
    queueIdentifierPatternField.sendKeys(identifierPattern);

    WebElement topicNameExactMatchField = driver.findElement(
            By.name(UIElementMapper.getInstance().getElement("mb.search.topic.name.exactmatch.tag.name")));
    // Set the name exact match check box state based on the test input
    if (isNameExactMatch != topicNameExactMatchField.isSelected()) {
        topicNameExactMatchField.click();
    }
    WebElement topicIdentifierExactMatchField = driver.findElement(
            By.name(UIElementMapper.getInstance().getElement("mb.search.topic.identifier.exactmatch.tag.name")));
    // Set the identifier exact match check box state based on the test input
    if (isIdentifierExactMatch != topicIdentifierExactMatchField.isSelected()) {
        topicIdentifierExactMatchField.click();
    }

    Select ownNodeIdDropdown = new Select(driver.findElement(By.id(UIElementMapper.getInstance()
            .getElement("mb.search.topic.own.node.id.element.id"))));
    ownNodeIdDropdown.selectByIndex(ownNodeIdIndex);

    driver.findElement(By.xpath(UIElementMapper.getInstance()
            .getElement("mb.search.topic.search.button.xpath"))).click();

}
 
Example 11
Source File: Ex03PO.java    From testing_security_development_enterprise_systems with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void createNewComment(String comment){
    WebElement textArea = getDriver().findElement(By.id("createForm:createText"));
    textArea.clear();
    textArea.sendKeys(comment);
    WebElement button = getDriver().findElement(By.id("createForm:createButton"));
    button.click();

    waitForPageToLoad();
}
 
Example 12
Source File: StepUtils.java    From OpenESPI-DataCustodian-java with Apache License 2.0 5 votes vote down vote up
public static void associate(String uuid, String description) {
	clickLinkByPartialText("Add Usage Point");

	WebElement uuidElement = driver.findElement(By.name("UUID"));
	uuidElement.clear();
	uuidElement.sendKeys(uuid);

	WebElement descriptionElement = driver
			.findElement(By.id("description"));
	descriptionElement.sendKeys(description);

	WebElement create = driver.findElement(By.name("create"));
	create.click();
}
 
Example 13
Source File: AttachFile.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
  File file = downloadFile(value);

  WebElement element = finder.findElement(driver, locator);
  element.clear();
  element.sendKeys(file.getAbsolutePath());

  return null;
}
 
Example 14
Source File: FeedbackSubmitPage.java    From teammates with GNU General Public License v2.0 4 votes vote down vote up
public void clearResponseTextBoxValue(int qnNumber, int responseNumber, int responseSubNumber) {
    WebElement element = browser.driver.findElement(
            By.id(Const.ParamsNames.FEEDBACK_RESPONSE_TEXT
                + "-" + qnNumber + "-" + responseNumber + "-" + responseSubNumber));
    element.clear();
}
 
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 fillField(String fieldName, String value) {
  WebElement field = browser.findElementByCssSelector(fieldName);
  field.clear();
  field.sendKeys(value);
}
 
Example 16
Source File: OpenIdConnectScopeAddPage.java    From oxTrust with MIT License 4 votes vote down vote up
public void setDescription(String des) {
	WebElement description = webDriver.findElement(By.tagName("textarea"));
	description.clear();
	description.sendKeys(des);
}
 
Example 17
Source File: ProfileSteps.java    From attic-rave with Apache License 2.0 4 votes vote down vote up
private void changeFieldValue(String fieldId, String value) {
    final WebElement field = portal.findElement(By.id(fieldId));
    field.clear();
    field.sendKeys(value);
}
 
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 fillField(String fieldName, String value) {
  WebElement field = browser.findElementByCssSelector(fieldName);
  field.clear();
  field.sendKeys(value);
}
 
Example 19
Source File: UserAddPage.java    From oxTrust with MIT License 4 votes vote down vote up
public void fillEmail(String email) {
	WebElement element = webDriver.findElement(By.className("Email"));
	element.clear();
	element.sendKeys(email);
}
 
Example 20
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) {

        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());
    }