Skip to content

Commit

Permalink
Добавлен метод по очистке полей. Изменен sendKeys на setValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Александр Долинский committed Jul 17, 2017
1 parent 8113ee1 commit 7b695cf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package ru.colibri.ui.steps.general;

import io.appium.java_client.MobileElement;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.When;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Keyboard;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;
Expand All @@ -19,7 +22,7 @@ public class TextFieldSteps extends AbsSteps {
public void sendKeys(@Named("$field") String field, @Named("$valueOrKeyword") String valueOrKeyword) {
WebElement webElement = getWebElementByName(field);
String value = propertyUtils.injectProperties(valueOrKeyword);
webElement.sendKeys(value);
((MobileElement) webElement).setValue(value);
}


Expand All @@ -39,4 +42,14 @@ public void sendText(@Named("$textOrKeyword") String textOrKeyword) {
String text = propertyUtils.injectProperties(textOrKeyword);
driver.getKeyboard().sendKeys(text);
}

@Step
@When("очистить \"$fieldName\"")
public void clearField(@Named("$fieldName") String fieldName) {
WebElement webElement = getWebElementByName(fieldName);
Keyboard keyboard = driver.getKeyboard();
for (int i = webElement.getText().length(); i > 0; i--) {
keyboard.sendKeys(Keys.BACK_SPACE);
}
}
}

0 comments on commit 7b695cf

Please sign in to comment.