Calabash Android: Check if a button is present and enabled - android

I am new to Calabash and sadly, possess no programming experience, so I hope people shall be patient with me and offer explicit answers.
On the Login page, I am successfully able to check for the...
Email Address field
Password field
but I can't seem to test for the presence and enabled state of the...
Sign in button
Hide button (to hide or show the Password typed)
Password Help and Recovery button
Using query("*"), I can obtain all the IDs but I'm stumped about the actual query commands with which to test.
This is my test thus far:
Feature: Sign In appearance
Scenario: Upon launch, all elements of the login page should appear correctly
Then I see "Email Address"
Then I see "Password"
Then I see "button marked:'Sign In'"
Which yields the following results:
Then I see "button marked:'Sign In'" # calabash-android-0.4.20/lib/calabash-android/steps/assert_steps.rb:5
Action 'assert_text' unsuccessful: Text'button marked:'Sign In'' was not found (RuntimeError)
features/Login_appearance.feature:6:in `Then I see "button marked:'Sign In'"'
Failing Scenarios:
cucumber features/Login_appearance.feature:3
How shall I proceed?

Instead of trying to use the predefined steps create a custom step and use the Ruby api's query and wait_for_elements_exist methods.
Take a look at this post first to learn more about the query language:
http://krazyrobot.com/2014/04/calabash-using-query/
Then find the elements with query possibly by id, eg.:
query("* id:'email_field'")
query("* id:'pwd_field'")
Create a custom step in your step definition and use the wait_for_elements_exist method to verify the elements:
Then /^all the elements are present on the login screen$/ do
wait_for_elements_exist(["* id:'email_field'", "* id:'pwd_field'"])
end

Have you tried replacing
Then I see "button marked:'Sign In'"
with
Then I see "Sign In"
?

Related

How to show Google's user and password saver message for future autofill logins in my app?

I have 2 EditText, one with Username and another with Password.
I want to save both in my googgle passwords for autofill in the future logins in the app.
How can achieve this?
Thank you!
EDIT:
I Tried this.
val options: CredentialsOptions = CredentialsOptions.Builder().forceEnableSaveDialog().build()
val mCredentialsClient = Credentials.getClient(this, options)
var credential = Credential.Builder(login_user_id.text.toString()).setPassword(login_user_password.text.toString()).build()
mCredentialsClient.save(credential).addOnCompleteListener{
Toast.makeText(this,"GUARDADO BRO", Toast.LENGTH_SHORT).show()
}
After i do de Login i execute that code. It shows the toast, but i want the Google Smartlock message to show up but it doesnt happen.
//EDIT2: Ok, the code from Above is for Google Smart Lock and its not what im looking for. I Want to see that native username with saved password box
Well, after an entire day of research i found the problem.
In the XML you have to set the inputType to the correct way. I already had that.
android:inputType="textPassword" --> For passowrd
android:inputType="textEmailAddress" --> for mail
And then, when you do the succesfull login you MUST to do finish() so in the background android do the magic and ask you to save the data in your google passwords or samsung pass or whatever.

How to create mention edit text like facebook

I want to create a edit text where user suggestions will be shown when user typed "#" keyword.
For eg. If the selected user is: "James test user".
And if user press delete character(back space in android keyboard.) then it should delete the word by word instead of characters. just like first user will be deleted then test and then james.
Any lead will be great for me.
I've tried the https://github.com/linkedin/Spyglass and https://github.com/hendraanggrian/socialview. But they won't fulfill my requirements.

How to set a part of validation in saripaar?

When I use android-saripaar I want to use only some of the validation. I used the ViewPager and had a dozen of EditText. Each page had some inputs. And I want to validate the inputs at every step.
For example, I had username and password at first step, and phone, email at the second. If user type in the invalid data at first step, validation worked.
Finally I find the answer in the ISSUE : https://github.com/ragunathjawahar/android-saripaar/issues/104#issuecomment-133822417

How to identify a Login Page of a App from my app using Accessibility in android

Hi. Using Accessibility, i am trying to auto fill username &
password of an any app from my app which is managing username &
password of all apps like dashlane. i found one way to auto fill
field value using Action_Paste. when user starts to focusing on
EditText it will get the AccessibilityNodeInfo by using getSource() method, using that it auto
fills EditText Filed, below is a code for above process.
Code:
AccessibilityNodeInfo source = event.getSource();
if (source != null) {
ClipboardManager clipboard = (ClipboardManager) MyAccessibilityService.this.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", "TEST DATA");
clipboard.setPrimaryClip(clip);
source.performAction(AccessibilityNodeInfo.ACTION_PASTE);
Toast.makeText(MyAccessibilityService.this, "Pasted Successfully", Toast.LENGTH_LONG).show(0;
}
Here i need to extend my ui like, it needs identify the login page, once its confirmed as a login page it will show the list of login item. based on user selection it will auto fill username field & password field.
Here i have two question
how to identify the login page of an app, i tried something like, when user clicks a First Edittext filed i will search for next node and check whether it is password filed or not? i used getchild() method. but does not give the child element. When login page loaded in app, i need identify whether it is login field or not? How can i identify a login page, please any tutorial welcome.
based on the source i am filling the field values. if i identified a login page then how to get AccessibilityNodeInfo of username & password. So that i can fill both fields rite?
i spent time for those problem.but i cant get any thing. please anyone can give deep explanation & tutorials for the above problems. thanks.
Use getRootInActiveWindow() to get the root node & iterate the tree to check all the nodes.
My answer here might help.
This way, you will find your Username & Password nodes.
Now, you can paste the text in these nodes.
But i will suggest to not use clipboard to fill passwords as there are some apps that continuously watch your clipboard.
Such apps can intercept your login credentials.

Tap on search Button in android device with appium is not working

I am trying to type in a search box within my app and tap/click on search button (magnifying glass) on keyboard. But I am unable to click/tap on it. I have tried below things: driver.sendKeyEvent(84); Appium says it successfully sent in the command but 'search' does not get tapped. Cursor remains in text box and results do not filter.
HashMap swipeObject = new HashMap();swipeObject.put("keycode", 84);((JavascriptExecutor ) driver).executeScript("mobile: keyevent", swipeObject);
Appium says: not yet implemented
find element by id or path and then use click.
driver.findElement(By.id("SearchButton-Id")).click();
driver.findElement(By.xpath("//xpath given by UIAutomator")).click();
If you can post the screenshot of UIAutomator, I can tell you xpath.
Use this for search button on keyboard:
driver.sendKeyEvent(AndroidKeyCode.ENTER);
For this, you need "import io.appium.java_client.android.AndroidKeyCode;"
Try below java code-
driver.executeScript("mobile: performEditorAction", ImmutableMap.of("action", "search"));
action: The name or an integer code of the editor action to be executed. The following action names are supported: normal, unspecified, none, go, search, send, next, done, previous

Categories

Resources