@When("^I delete the text '(.+?)' on the element on index '(\\d+?)'( and replace it for '(.+?)')?$")
    public void seleniumDelete(String text, Integer index, String foo, String replacement) {
        assertThat(this.commonspec, commonspec.getPreviousWebElements()).as("There are less found elements than required")
                .hasAtLeast(index);

        Actions actions = new Actions(commonspec.getDriver());
        actions.moveToElement(commonspec.getPreviousWebElements().getPreviousWebElements().get(index), (text.length() / 2), 0);
        for (int i = 0; i < (text.length() / 2); i++) {
            actions.sendKeys(Keys.ARROW_LEFT);
            actions.build().perform();
        }
        for (int i = 0; i < text.length(); i++) {
            actions.sendKeys(Keys.DELETE);
            actions.build().perform();
        }
        if (replacement != null && replacement.length() != 0) {
            actions.sendKeys(replacement);
            actions.build().perform();
        }
    }
@ When ( "^I delete the text '(.+?)' on the element on index '(\\d+?)'( and replace it for '(.+?)')?$" ) public void seleniumDelete ( String text , Integer index , String foo , String replacement ) { assertThat ( this . commonspec , commonspec . getPreviousWebElements ( ) ) . as ( "There are less found elements than required" ) . hasAtLeast ( index ) ; Actions actions = new Actions ( commonspec . getDriver ( ) ) ; actions . moveToElement ( commonspec . getPreviousWebElements ( ) . getPreviousWebElements ( ) . get ( index ) , ( text . length ( ) / 2 ) , 0 ) ; for ( int i = 0 ; i < ( text . length ( ) / 2 ) ; i ++ ) { actions . sendKeys ( Keys . ARROW_LEFT ) ; actions . build ( ) . perform ( ) ; } for ( int i = 0 ; i < text . length ( ) ; i ++ ) { actions . sendKeys ( Keys . DELETE ) ; actions . build ( ) . perform ( ) ; } if ( replacement != null && replacement . length ( ) != 0 ) { actions . sendKeys ( replacement ) ; actions . build ( ) . perform ( ) ; } }
Delete or replace the text on a numbered {@code index} previously found element.

@param index