Skip to content

Commit

Permalink
Merge pull request #14 from alfa-laboratory/revert_clear_field_method
Browse files Browse the repository at this point in the history
revert clearField method to loop strategy
  • Loading branch information
JasperJhons committed Aug 29, 2017
2 parents cd8fca1 + 9b84e67 commit 22ae1de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
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 Down Expand Up @@ -41,10 +43,12 @@ public void sendText(@Named("$textOrKeyword") String textOrKeyword) {
driver.getKeyboard().sendKeys(text);
}

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

0 comments on commit 22ae1de

Please sign in to comment.