Java Code Examples for com.codeborne.selenide.SelenideElement#setValue()

The following examples show how to use com.codeborne.selenide.SelenideElement#setValue() . 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: InputInteractionSteps.java    From akita with Apache License 2.0 6 votes vote down vote up
/**
 * Ввод в поле текущей даты в заданном формате
 * При неверном формате, используется dd.MM.yyyy
 */
@Когда("^элемент \"([^\"]*)\" заполняется текущей датой в формате \"([^\"]*)\"$")
@When("^element named \"([^\"]*)\" has been filled with current date in format \"([^\"]*)\"$")
public void currentDate(String fieldName, String dateFormat) {
    long date = System.currentTimeMillis();
    String currentStringDate;
    try {
        currentStringDate = new SimpleDateFormat(dateFormat).format(date);
    } catch (IllegalArgumentException ex) {
        currentStringDate = new SimpleDateFormat("dd.MM.yyyy").format(date);
        log.error("Неверный формат даты. Будет использоваться значание по умолчанию в формате dd.MM.yyyy");
    }
    SelenideElement valueInput = akitaScenario.getCurrentPage().getElement(fieldName);
    valueInput.setValue("");
    valueInput.setValue(currentStringDate);
    akitaScenario.write("Текущая дата " + currentStringDate);
}
 
Example 2
Source File: InputInteractionSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Устанавливается значение (в приоритете: из property, из переменной сценария, значение аргумента) в заданное поле.
 * Перед использованием поле нужно очистить
 */
@Когда("^в поле \"([^\"]*)\" введено значение \"(.*)\"$")
@When("^into the field named \"([^\"]*)\" has been typed value \"(.*)\"$")
public void setFieldValue(String elementName, String value) {
    value = getPropertyOrStringVariableOrValue(value);
    SelenideElement valueInput = akitaScenario.getCurrentPage().getElement(elementName);
    cleanField(elementName);
    valueInput.setValue(value);
}
 
Example 3
Source File: InputInteractionSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Добавление строки (в приоритете: из property, из переменной сценария, значение аргумента) в поле к уже заполненой строке
 */
@Когда("^в элемент \"([^\"]*)\" дописывается значение \"(.*)\"$")
@When("^element named \"([^\"]*)\" has been suplemented with value of \"(.*)\"$")
public void addValue(String elementName, String value) {
    value = getPropertyOrStringVariableOrValue(value);
    SelenideElement field = akitaScenario.getCurrentPage().getElement(elementName);
    String oldValue = field.getValue();
    if (oldValue.isEmpty()) {
        oldValue = field.getText();
    }
    field.setValue("");
    field.setValue(oldValue + value);
}
 
Example 4
Source File: InputInteractionSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Ввод в поле случайной последовательности латинских или кириллических букв задаваемой длины
 */
@Когда("^в поле \"([^\"]*)\" введено (\\d+) случайных символов на (кириллице|латинице)$")
@When("^into the field named \"([^\"]*)\" has been entered (\\d+) random (?:latin|cyrillic) symbol(|s)$")
public void setRandomCharSequence(String elementName, int seqLength, String lang) {
    SelenideElement valueInput = akitaScenario.getCurrentPage().getElement(elementName);
    cleanField(elementName);

    if (lang.equals("кириллице")) lang = "ru";
    else lang = "en";
    String charSeq = getRandCharSequence(seqLength, lang);
    valueInput.setValue(charSeq);
    akitaScenario.write("Строка случайных символов равна :" + charSeq);
}
 
Example 5
Source File: InputInteractionSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Ввод в поле случайной последовательности латинских или кириллических букв задаваемой длины и сохранение этого значения в переменную
 */
@Когда("^в поле \"([^\"]*)\" введено (\\d+) случайных символов на (кириллице|латинице) и сохранено в переменную \"([^\"]*)\"$")
@When("^into the field named \"([^\"]*)\" has been entered (\\d+) random (?:latin|cyrillic) symbol(|s) and saved to variable named \"([^\"]*)\"$")
public void setRandomCharSequenceAndSaveToVar(String elementName, int seqLength, String lang, String varName) {
    SelenideElement valueInput = akitaScenario.getCurrentPage().getElement(elementName);
    cleanField(elementName);

    if (lang.equals("кириллице")) lang = "ru";
    else lang = "en";
    String charSeq = getRandCharSequence(seqLength, lang);
    valueInput.setValue(charSeq);
    akitaScenario.setVar(varName, charSeq);
    akitaScenario.write("Строка случайных символов равна :" + charSeq);
}
 
Example 6
Source File: InputInteractionSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Ввод в поле случайной последовательности цифр задаваемой длины
 */
@Когда("^в поле \"([^\"]*)\" введено случайное число из (\\d+) (?:цифр|цифры)$")
@When("^into the field named \"([^\"]*)\" has been entered (\\d+) random digit(|s)$")
public void inputRandomNumSequence(String elementName, int seqLength) {
    SelenideElement valueInput = akitaScenario.getCurrentPage().getElement(elementName);
    cleanField(elementName);
    String numSeq = RandomStringUtils.randomNumeric(seqLength);
    valueInput.setValue(numSeq);
    akitaScenario.write(String.format("В поле [%s] введено значение [%s]", elementName, numSeq));
}
 
Example 7
Source File: InputInteractionSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Ввод в поле случайной последовательности цифр задаваемой длины и сохранение этого значения в переменную
 */
@Когда("^в поле \"([^\"]*)\" введено случайное число из (\\d+) (?:цифр|цифры) и сохранено в переменную \"([^\"]*)\"$")
@When("^into the field named \"([^\"]*)\" has been entered (\\d+) random digit(|s) and saved to variable named \"([^\"]*)\"$")
public void inputAndSetRandomNumSequence(String elementName, int seqLength, String varName) {
    SelenideElement valueInput = akitaScenario.getCurrentPage().getElement(elementName);
    cleanField(elementName);
    String numSeq = RandomStringUtils.randomNumeric(seqLength);
    valueInput.setValue(numSeq);
    akitaScenario.setVar(varName, numSeq);
    akitaScenario.write(String.format("В поле [%s] введено значение [%s] и сохранено в переменную [%s]",
            elementName, numSeq, varName));
}