serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
718 stars 515 forks source link

Appium Behaviour Different from WebDriver SendKeys #945

Closed David-Paterson closed 6 years ago

David-Paterson commented 6 years ago

When using EnterValue action the first call to sendKeys works and the value is entered correctly.

However, the second call to sendKeys using an empty followedByKeys list blanks the correct value entered.

    @Step("{0} enters '#theText' into #target")
    public <T extends Actor> void performAs(T theUser) {
        target.resolveFor(theUser).sendKeys(theText);
        target.resolveFor(theUser).sendKeys(getFollowedByKeys());

    }

I have tried adding Key Up, Key Right, Tab and Enter all replace the correct value with an undisplayable character.

My action:

 actor.wasAbleTo(
     Enter.theValue(userName).into(LoginTargets.USERNAME_FIELD),
     Enter.theValue(password).into(LoginTargets.PASSWORD_FIELD),
     Click.on(LoginTargets.LOGIN_BUTTON)
 );

Work-around:

WebDriver driver = BrowseTheWeb.as(actor).getDriver();

driver.findElement(By.id("com.bjss.mymapp.debug:id/edit_username")).sendKeys(userName);
driver.findElement(By.id("com.bjss.mymapp.debug:id/edit_password")).sendKeys(password);
driver.findElement(By.id("com.bjss.mymapp.debug:id/button_login")).click();

Platform: Android Serenity: 1.6.0 Appium: 1.6.5

wakaleo commented 6 years ago

Is the issue when getFollowedByKeys() returns an empty list, or when you provide a value?

David-Paterson commented 6 years ago

It happens for both.

If the list is empty it blanks the value completely.

If the list contains a Key such as Right or Tab or Return, the value is replaced by an undisplayable char.

wakaleo commented 6 years ago

Could you try with this action instead:

public class EnterValueIntoTarget extends EnterValue {

    private Target target;

    public EnterValueIntoTarget(String theText, Target target) {
        super(theText);
        this.target = target;
    }

    @Step("{0} enters '#theText' into #target")
    public <T extends Actor> void performAs(T theUser) {
        target.resolveFor(theUser).type(theText);
        if (getFollowedByKeys().length > 0) {
            target.resolveFor(theUser).sendKeys(getFollowedByKeys());
        }
    }
}
David-Paterson commented 6 years ago

That works on the device farm using remote driver 👍 and on the local android driver.

David-Paterson commented 6 years ago

The patch fix's the issue.

David-Paterson commented 6 years ago

Sorry was closed in error.

David-Paterson commented 6 years ago

Doing further tests the keyboard popup seems to be inconsistent.

wakaleo commented 6 years ago

So this is an issue with the Appium Driver?

David-Paterson commented 6 years ago

It may well be, not sure as I get the inconsistent result using both the action and the work-around.

Anyway, the original issue is fixed thanks :)

wakaleo commented 6 years ago

It will be in the next release :-)

David-Paterson commented 6 years ago

I have found that setting the following prevents the soft keyboard from being displayed on Android not sure if it works for iOS.

serenity.driver.capabilities="unicodeKeyboard:true;resetKeyboard:true"