I'm new to Robotium as well as Android. I have written some code to test an activity. and that activity is opening a dialogue box. and i'm not able to identify it. I tried solo.getCurrentActivity(), not workes. I tried solo.searchText(). But test is failing.
write code like this
if (solo.waitForActivity("HomePhone", 20000)) {
if(solo.waitForText("xxx*",1,10000)){
if(solo.waitForText("ok*",1,5000)){
solo.clickOnText("ok*");
}else{
solo.goBack();
}
}
wait for text is best method for your purpose
Related
How do I make my Text-To-Speech stop speaking? Right now, my TTS will start speaking when I launch my application, but I'm trying to make it stop speaking when a button on my Main Activity is pressed.
I have tried creating an onStop() method and using .stop, but to no avail.
May I please get some help on this issue?
You could do something along the lines of this ...
stopSpeakingButton.setOnClickListener(new
View.OnClickListener() {
String toSpeak = " ";
textToSpeech.speak(
toSpeaks,TextToSpeech.QUEUE_FLUSH,null);
});
As you gave us no code this a concept , not the most beautiful solution but will work if you adjust for your use case, the idea is to make it read string with onny a space in it!
Is there any way to do the following process in android Automation using Appium with android driver?
Press home button from some specific screen.
Put app in background.
Open the app from same screen after some time interval.
Please help if anybody knows.
Both iOS and Android support the following methods :
(AppiumDriver)driver.runAppInBackground(10);//put app in background for 10 seconds
(AppiumDriver)driver.launchApp();//launch the app again
Hope it helps!
Try to focus on the current activity you were in :
(AppiumDriver)driver.runAppInBackground(10);
(AppiumDriver)driver.currentActivity();
or
Try to start the same activity you were in :
(AppiumDriver)driver.runAppInBackground(10);
(AppiumDriver)driver.startActivity("appPackage","com.example.android.apis", null, null);
Put App in background:
((AndroidDriver)driver).runAppInBackground(Duration.ofSeconds(20));
To start App from background:
driver.activateApp("app package name");
driver.runAppInBackground(Duration.ofSeconds(10));
appium_lib ruby client allows you to do this with
background_app 5 where 5 is the number of seconds you want the app to be in background. This will automatically, resume the application in the same screen.
Here it is how it works.
Code for Running the App in back ground
((AppiumDriver)driver).runAppInBackground(Duration.ofSeconds(10));
Get back back to the current activity again
((StartsActivity)driver).currentActivity();
public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("appPackage", "appActivity");
} catch (Exception e) {
e.printStackTrace();
}
}
You have to enter your app package name and activity name to maximize the app.
For Eg:
public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("com.example.test", "com.example.LaunchApp");
} catch (Exception e) {
e.printStackTrace();
}
}
This will definitely work.
Works for me: ((Appium 1.10, Android 8.1))
2 options:
1st solution:
driver.runAppInBackground(Duration.ofMillis(300));
After you close your popUp, you use this line and your app will go to background and back and you will get back the focus to your app.
2nd solution: better one :)
Add this line to settings:
capability.setCapability("noReset", true);
From now your app will start like normal app, without setting reset what means without pop-ups and you will not have problem with focus at all.
I hope it will work also for you! :)
This will navigate to the Gmail App while executing your Appium script. You Just Change the package name & activity of your app.
Activity activity = new Activity("com.google.android.gm", "com.google.android.gm.ConversationListActivityGmail");
activity.setStopApp(false);
((AndroidDriver<MobileElement>) driver).startActivity(activity);
You can use this snippet of code
((AppiumDriver)driver).runAppInBackground(Duration.ofSeconds(10));
((StartsActivity)driver).currentActivity();
If it is not working then please update your appium with the latest version and try with the same snippet of code.
Thanks
I am using the official PlayGameServices plugin for Unity, and have been following the installation to the point. Authentication seems to work like a charm, but when I want to do the ShowAchievementsUI();, nothing happends. No UI, no errors, no crashes.
Ive been googling around for a while, it seems other people have hit this problem, but with no solution in sight.
My code at the moment is :
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
void Start() {
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
LoginSocialGamecenter();
}
public static void LoginSocialGamecenter() {
if (Social.localUser.authenticated) {
Social.ShowAchievementsUI (); Debug.Log("Pancakes!");
return;
}
}
And "Pancakes!" comes out perfectly. Authentication UI on first install also shows up nicely. It fails on all devices I have, but the debug message shows up perfectly on Android.
According to the documentation, it should work as described:
Showing the Achievements UI
To show the built-in UI for all leaderboards, call
Social.ShowAchievementsUI.
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
...
// show achievements UI
Social.ShowAchievementsUI();
This will show a standard UI appropriate for the look and feel of the platform (Android or iOS).
Akhil got it right. There needs to be more than five achievements or the window won't appear.
It will make no error reports on this, simply return false.
Specifically, I'm seeing this issue on an Android tablet, but I'm told it's with ALL mobile devices -- iPhones, Nexus tablets, etc.
But I have the common problem of change events not firing. Here's the function code that has the click events assigned:
function do_this(with_this_data)
{
var that = this;
this.with_this_data = with_this_data;
this.period = 900;
this.updateHours();
$('#date').change(function() {
that.updateHours();
});
$('#time_hour').change(function() {
that.updateMinutes();
});
// extra irrelevant data trimmed out
}
Now...one fix that should work is to move those .change() statements into a $(document).ready block -- but the problem is, if I do, then i get all sorts of undefined variable issues and stuff....all of the "update" functions are within said $(document).ready block and defined by names like "FutureStuff.prototype.updateMinutes."
What are my options???
Mifeet, again, I appreciate your feedback; I know you weren't able to fully get me up and running, but I'm still thankful.
But anyway, I solved the issue...it meant that basically I had to rewrite a new version of the JS code and stick it in an "if this chap is using a mobile browser" block. So yeah, one huge block of code for desktop users, another for mobile...but it works. :) And it was a pain in the hiney.
I followed instructions from the official zxing website and created an application using the following code. I tried to send the signed .apk file to my Samsung GSII for testing. The program stopped immediately after I clicked on the application's icon.
I am really sorry for my poor description and wordings.
Instead of using the embedded method,I finally used the IntentIntegrator for the program, as embedded one is too hard for me to understand.
Now I am facing another issue. I have wrote an onClick Method with the following statements:
public void Button1(View view){
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.initiateScan();
EditText editText2 = (EditText) findViewById(R.id.editText2);
editText2.setText(a);
}
How can I change the code so that it waits until the initiateScan() method finished before the setText() method operate? Actually I would like to use the returned result from initiateScan() as a condition.
Thanks again!
You don't wait for initiateScan() to finish. This function invokes the Barcode Scanner application. You wait for the result instead by implementing onActivityResult() in your app. This is documented in the wiki and in the javadoc. Did you read any of that, at all?