I am playing around with Xamarin UITest and I have noticed that on my Android device (Samsung S10E, v. 10) Xamarin UITest (v. 3.0.7) when I tap on an entry text element I cannot then enter text inside of that element.
The entry element is focused with the cursor inside of the entryfield and the keyboard is displayed, but no text is entered. To add another level of complexity, my test PASSES and does not FAIL even though the text was never entered.
Here is my code:
app.WaitForElement(c => c.Class("UsernameID"));
Thread.Sleep(3000);
app.EnterText(c => c.Id("UsernameID"), "Password1");
Also, tried this:
app.EnterText(c => c.TextField("LoginUserIDEntry"), "oaqa_Clark6_ps");
I inserted a thread sleep in case the keyboard was not loading in time for the EnterText call.
The same code on iOS works perfectly fine.
I understand that Xamarin.UITest does not use the soft keyboard. Instead, it injects itself between the soft keyboard and the application and simulates key presses. Whereas iOS actually simulates the presses on the keyboard.
Can anyone tell me if this is a syntax issue, device specific issue, or Xamarin issue?
In order to identify xamarin element you need to use either x:Name or even AutomationId field in shared project xaml.
Class will try to find it by Class name in native android or iOS. It's highly unlikely that class names in both platforms are same as you seems to have mentioned in the first code block.
To be generic you should mostly use Marked should work UITest projext
<Entry x:Name="entryXName" AutomationId="entryAutoId" />
app.EnterText(c => c.Marked("entryXName"), "oaqa_Clark6_ps");
//by id
app.EnterText(x=> x.Id("entryAutoId"),"foobarblahblackship");
There is whole good documentation here on official site
You can check sample as well.
I have learnt that Thread.Sleep will block UI main thread,instead you should use await Task.Delay
Related
I am trying to write UI tests for RTL language. Here is a scenario. I have an AutoCompleteTextView, on which when I try to tag a user ("#user"), it shows dropdown of suggested users. This works for RTL & LTR languages when I manually type the strings.
However, if I try to test using espresso the functionality it doesn't work as expected.
Here is how I am trying to write UI test :
Whenever I tell edit text to type “#u” using onView(withId(R.id.message_input_field)).perform(typeText("#u")), Espresso generates key events to inject the characters into edit text. Something like, KEY_DOWN_SHIFT, KEY_DOWN_2, KEY_UP_SHIFT, KEY_UP_2, this types “#” and so on. Everything works fine for English language.
Problem occurs when we try to tag using RTL characters, using something like onView(withId(R.id.message_input_field)).perform(typeText("#פ")). Espresso fails to recognize the RTL characters & can not generate key events, eventually throws java.lang.RuntimeException: Failed to get key events for string פ (i.e. current IME does not understand how to translate the string into key events)
I tried to do replaceText(…) instead of typeText(…) but replaceText in turn does editText.setText(…). but it doesn’t show the drop down. Weird.
How do I write UI test for this scenario?
P.S. It doesn’t matter what is your device language or what is you currently selected keyboard is.
I am using the ion-datetime-picker in my ionic project. Everything works fine when I debug it in web browser. When I run it on real device, I found a problem. The input text doesn't update. I check it with chrome://inspect/#devices, I see that the value of the input (model) changes even though the text in the input not changing.
I have added new issue here, hopefully anybody here can help too. Many thanks in advance.
UPDATE
I have tried to add a callback too in this plugin with ng-click, and pass the value accordingly to the scope and after that do some triggerHandler to the input.
$scope.changeme = function(val) {
alert(val)
}
The strength is it alert the value three times. The first time it alert the full date description, the second time it alert with time format as expected like 13:30, and finally the last time it only alert Nan:Nan
I also did $scope.$apply() and it still doesn't help.
Please help. I spent my whole night only for this thing. Thanks in advance.
The plugin (made by me) is not meant to be used with <input> element. Why?
It uses ng-model and it's modelValue-viewValue mechanism which is in conflict with ng-model mechanism of input element
It uses Date instance as it's model, which is in conflict with plain string model of input element
The directive marks element that, when tapped, would open the picker. Tapping input element already has it's own meaning - focusing it.
Use <div ion-datetime-picker ng-model="x">{{x | someFilter}}</div> or whatever fits your needs instead.
See #25 and #21 for more info.
I am writing an accessibility service. I've been trying to focus EditText fields in a way that pops up the software keyboard and I have been unsuccessful. I am able to get the cursor into the EditText field, but the soft keyboard doesn't pop up. Given EditTextNode is an AccessibilityNodeInfo that I have gotten from various accessibility events and that said nodeInfo isEditable, isFocusable, isVisibleToUser and isClickable when I attempt all of these actions and they all return true upon completion.
editTextNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
In my mind the above should simply work, and the fact that it does not is a bug in the Accessibility API, if not for my entire android version, at the very least on my device (Droid Ultra, Android 4.4.4). I have also tried:
editTextNode.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
Puts focus into the field so I can see the input cursor, but no keyboard.
editTextNode.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
Doesn't really do anything unless talkback is enabled.
editTextNode.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, someBundle);
Along with appropriate arguments this will work, but only if there is already text in the editText field. I need to pull the keyboard up on empty text fields as well. Yes, I tried inputing 0,0 for start and end text selection arguments. The SET_SELECTION method only works with text in the field!
This has been frustrating me for a couple days, hopefully you guys can help. Though I believe I've stumbled onto a bug and am going to have to wait for Android to update. Because the ACTION_CLICK method should really be all that is needed. But, I could be missing something silly, Accessibility API Doc is somewhat scant. Am willing to attempt anything.
To restate #alanv's comment in answer form:
You are correct, it is a bug in accessibility services prior to API 21.
I have a problem since a long time and I have not find a way of solving it.
My app as a webview that loads an url where the user can fill certain text inputs, also, the app produces sounds in certain situations(to help/assist the users), the problem is that, sometimes when the user is writing in an input and some sound is triggered the soft keyboard hides because the input lost its focus.
This is quite annoying to the users because they have to touch the input again to continue writing.
Any ideas about how to solve it?
I was confused on this same issue but I learned that it is common practice to call search.blur() (assuming we are talking about a search text input field) when a window.resize event is triggered for desktop, but sometimes that same code causes issues on mobile because the virtual keyboard triggers a resize event as well. If this is the case, you may have to use something like modernizr to determine if you are in a mobile device context and if so don't call that search.blur(). Search your code base for the blur() pattern to see if that is what is happening for you.
To fix, try something like this:
window.onresize = function () {
if (!isMobile) {
search.blur()
}
}
When entering a string in a text type input element in a webview based app, a list of possible words is showed above the virtual keyboard.
In my application the user is not allowed to input arbitrary words, instead only words and phrases from a database are legal.
So, I want to set the list of words from my phonegap app and disable the automatic creation of this list.
Q: Is this possible to create the list - and how?
(This is a phonegap app and I am testing on android, but this might be a problem for webview / text input fields on different platforms)
EDIT:
Just found out (yes, I'm new to android development), that one can disable the suggestion list with: Settings / Language and Keyboard / Android keyboard / Show suggestions.
But of course, this setting should be made only for the app, from inside the app, without user interaction and not changing anything outside the app.
Any chance to get this done?
EDIT 2:
Instead of disabling the suggestion list I tried to use it.
The displayCompletions method of InputMethodManager sounded promising, so I tried the following code:
...
// data member
InputMethodManager mInputMethodManager = null;
...
...
// initialized
mInputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
...
public void showSuggestions(String[] words) {
Log.d(TAG, "showSuggestions (in Java!): " + words.length); // yes, this code is executed
CompletionInfo[] completions = new CompletionInfo[words.length];
for (int i=0; i<words.length; i++) {
completions[i] = new CompletionInfo(i, i, words[i]); // no idea, what the 2 extra integers mean
}
mInputMethodManager.displayCompletions(mView, completions);
}
The method is executed, whenever a new list is available (after the input has changed and the server has answered a request).
However, nothing has changed - the builtin mechanism is still doing its disadvantageous work.
Why don't you use something like the auto complete in jQuery UI.
http://jqueryui.com/demos/autocomplete/
Also, it's not too hard to whip this up yourself in JavaScript.
http://www.javascript-examples.com/autocomplete-demo/
In case there are different variants of virtual keyboard(swype and others) there might be no list of possible words. So, I suppose there is no general solution for not showing this list.
There is a parameter http://developer.android.com/reference/android/widget/TextView.html#attr_android:editorExtras editorExtras which defines parameters passed to input method implementation, but I'm not sure how would you use it in PhoneGap application
Edit:
I suppose you can extend default input method and make it not to show suggestions
inputmethod reference http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html
Providing Custom Software Keyboards
If you are interested in developing your own software keyboards, we highly recommend the following references:
IMEs are implemented as an Android service. Begin by reviewing the Android packages called android.inputmethodservice and android.view.inputmethod, which can be used to implement custom input methods.
The SoftKeyboard sample application in the Android SDK provides an implementation of a software keyboard.
The Android Developer technical articles on onscreen input methods and creating an input method.
found it here http://e-university.wisdomjobs.com/android/chapter-946-288/handling-advanced-user-input.html