Is it possible to send a tab key press with calabash? I'm having difficulty selecting elements in a browser view on Android.
I've tried the following things:
enter_text("WebView css:'#Email'", "email#email.com")
enter_text("android.widget.EditText id:'#Email'", "email#email.com")
But they don't seem to be seen by calabash to select. I'm now wondering if I send certain number of tab presses, I should also end up in the field that I want. How do I send a tab key press though?
Additionally, is it possible to send text to an element that has the active focus, without specifying an id of the element?
Thanks in advance
"Is it possible to send a tab key press with calabash?"
Yes, it is.
press_user_action_button('next')
If you are using Cordova, you should change the Webview to cordovaWebView or SystemWebView.
enter_text("SystemWebView css:'#Email'", "email#email.com")
"Additionally, is it possible to send text to an element that has the active focus, without specifying an id of the element?"
Yes, it is.
keyboard_enter_text("text")
Related
in android stuido I would like to code an activity, where the user can input numbers. For, example he types the number to the textfield, click 'OK' button, then the textfield gets clear, he types the second number, than the third, and after they give the third number the program goes to another activity and sayst thanks for the free number. I would like to save the three numbers for further use and have them in an ascending order. How should I do it?
I agree with Andrii, this is a very vague and general question. To get you pointed in the right direction though, you would want a layout with an number based-editText widget (for the user input). I would then add the button, and then implement OnClickListener for the button so that everytime the button is pressed, it calls a method you will define that will store the value in an array or list (which can be sorted), along with some kind of tracker to keep track of how many numbers have been entered - then clearing the editText field so that another number can be input; on the third number, the method calls the activity via intent or some other way saying "thanks for the free number".
This is all general and it is going to take quite a bit of work and API Guide/DeveloperDocs searching on the Android web site.
WebElementUserAccount=driver.findElement(By.xpath("//android.widget.EditText[#content-desc='User account']"));
UserAccount.click();
UserAccount.sendKeys("Test");
When I use this code it is not releasing the User account element it sends the text successfully but not came out of it
In the second element, I have to send the password but it will not come out from the first Element
When I use
WebElement UserName= driver.findElement(By.xpath("//android.widget.EditText[#content-desc='User account']"));
WebElement Password= driver.findElement(By.xpath("//android.widget.EditText[#content-desc='Password']"));
UserName.sendKeys("UserName");
The Android keybord open before sending the text and it starts writing in the second element
Use driver.hideKeyboard(); after entering text in your first element. Your keyboard might be hiding next element.
Whenever you do automation its better to turn off the text suggestion(predictive text) in the mobile keyboard.
Check whether the keyboard is displayed . If displayed use the following code:
driver.hideKeyboard();
I'm making a very simple launcher for Android. I'm having trouble getting some speed dial buttons to work.
The idea is that when the user presses the speed dial buttons for the first time, they'll be prompted to enter a phone number with a popup window (dialog? I think?). That number will then be assigned to that button, which will then call the assigned number when the button is next pressed. It's not great if they want to reassign a number, but this is just something rough that i'd like to get out of the way. I'm thinking of creating an int to reflect the state of the button (0 = no number assigned, 1 = number is assigned), and using if statements to either bring up the window or call the number.
I don't know how to bring up such a window (although I do know I can bring up a dial pad using (android:inputType="phone")), as well as how to pass the number that the user inputted to an int/long. I'm thinking I can assign the value to an int, although that might not be the most optimal data type. I have a rough idea on how to dial a number once it's given.
What should I do? I'm quite new to programming, so i'm having trouble with this.
may be this could help.
have a long click listener to the buttons.
on long click event, show a dialog widow which accepts the number.
store it in a persistent memory, either db, files or pref utils by android.
in on click button, have a logic to retrieve the stored content and update the views accordingly.
I have successfully added a word to Android's predefined user dictionary, but i want to create a custom dictionary which can only be accessed by my application.
For example: When i type "lol", the suggestions show me "laugh out loud" but when I want another meaning of "lol" then I can manually add another meaning of "lol" (eg, "xxxxxx" - so the next time the user writes "lol" in an EditText, the suggestions will show him "xxxxxx").
No other application should have access my dictionary data.
I have worked with spell checker class but it gives me only correct word and I can't my own word meanings.
Please give me some suggestions or links.
There is an Androids inbuilt class UserDictionary so that you can add your spells programmatically into that, Here is a link you can go through with , and which may relates to your problem .(In this solution nidhi has manged programmatically to retrieve data back)
Add word to user dictionary and retrieve them back from dictionary
In addition you can go through following links to :
http://developer.android.com/reference/android/provider/UserDictionary.html
http://developer.android.com/reference/android/provider/UserDictionary.Words.html
Moreover if you want a custom personal dictionary then manually you have to store words and retrieve them back .
Hope that helps !!!
I want to make a smart keyboard that can learn and save new words from user. I already made note and keyboard separately, the problem is :
how to read all keystrokes and write it to my note in background?
how to save my note automatically?
thanks for your help
Keep a String or StringBuilder that stores all the text that the user types. All text sent through your soft keyboard will have to pass through the onKey method.
So, I'd do something like this:
1) In onKey, check to make sure primaryCode (the keycode that was pressed) is a letter/number/apostrophe using the corresponding functions. So, something like
Character.isDefined(primaryCode)
2) Concatenate primaryCode onto the end of your StringBuilder/String.
You'll also have to deal with the user moving the cursor/backspacing. In my keyboard, I only store the most recent two words (resetting this whenever the user moves the cursor). That way, the keyboard can learn what the most likely word is given the last word.
You can save your "note" using an ObjectOutputStream or (if it's fairly small) using sharedPreferences.
Send me an email if you run into an more issues: I've been writing a soft keyboard for a while so I'm pretty familiar with it.