0

I am writing a test case for an android app where the app requires case-sensitive credentials. I writing test cases using appium and TestNG.

Steps I am following are -

  1. Launching app
  2. Entering username and password e.g. username : user_test and password : User@123
  3. Tapping on Login button.

Result

  1. App launched successfully.
  2. Entered wrong credentials username: user_test and password: USer@123

The problem here is that it's entering the wrong password. Two characters of a password in upper-case: USer@123.

The function I use to enter text in the password field is -

inspectElement(XpathConstants.PASS_TXT_XPATH).sendKeys("User@123");
  • 1
    So basically you are able to enter case-sensitive credentials but there is some issue with sending the proper keys? – Alexey R. May 21 '18 at 13:32
  • Can you please check you have to test password with 2 letters in capital case- in your question "USer@123" and in your script there is only one letter in capital case "User@123" – Bharat Mane May 21 '18 at 13:57
  • What it enters in password field right now? – Bharat Mane May 21 '18 at 13:59
  • I am entering "User@123", but its typing "USer@123". Yes, some issue with sending the proper keys? @Alexey – Ravi Ojha May 21 '18 at 14:01
  • Try to invoke sendKeys for each particular symbol of your password. – Alexey R. May 21 '18 at 14:10
0

Try breaking it down into three steps:

WebElement password = inspectElement(XpathConstants.PASS_TXT_XPATH);
password.clear();
password.sendKeys("User@123");
  • Tried but still same problem exists. Any other way ? – Ravi Ojha May 21 '18 at 13:57
  • 1
    I've never seen the behavior you're describing before. I would do a global search of my source code for "USer" (obviously case-sensitive search) to see if there is somehow some other code that is getting executed instead of the code you think is getting executed. If all else fails, I would change the password to some other mixed case word and see if the problem persists. – Bill Hileman May 21 '18 at 14:21
  • Right, I tried the exact Scenario with my current Android version 4.4.2 and it works well.. I shocked with this crazy behavior.. Need to search more on this.. – Bharat Mane May 21 '18 at 14:38
0

If nothing else works, you can do the truly horrible workaround of adding a delay to each letter entered (this is assuming that the time to switch from upper-case to lower-case is what is causing your problem).

Your code would do something like this (no guarantees that the code is actually correct - it's a long time since I've worked with Java - but the principle is sound)

string password = "User@123";
char[] pwdArray = password.toCharArray();
for (int i = 0; i < pwdArray.length(); i++) 
{
   passwordElement.sendKeys(pwdArray[i].toString());
   thread.sleep(5); // Adjust the sleep time until entry doesn't take too long but gives the correct result
}

Make no mistakes, this is a horrible way to fix this problem, but it may be the only way you can do it - especially if you are testing with different credentials.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.