Re: [robotium-developers] Problem with Robotium detecting correct activity (looking for work around)

362 views
Skip to first unread message

Renas

unread,
Jun 4, 2013, 12:26:32 AM6/4/13
to robotium-...@googlegroups.com

Hi,

Use waitForActivity or assertCurrentActivity.

/Renas

On 4 Jun 2013 06:25, "CG" <slid...@gmail.com> wrote:
I'm trying to get started with Robotium.  I figured our login page would be a good place to start.  This is the way our login page currently works:

1) Start the UserProfile activity
2) If user is not logged, start the Login activity
3) User enters login criteria, clicks log in.  This logs the user in and finishes the Login activity, returning to Profile

I'd like to test that the user's click on the login button correctly logs the user in and returns to the Profile activity.  To do this I based my test on the UserProfile activity.  However I can't get my test case to recognize that the activity has changed from UserProfile to Login.  The posts I've seen suggest that I should base my test on the Login activity.  This works fine until the user clicks login and the activity finishes with nowhere to return to.

Any suggestions for how I can get this to work in Robotium?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotium-develo...@googlegroups.com.
To post to this group, send email to robotium-...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotium-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Renas Reda

unread,
Jun 5, 2013, 2:23:03 PM6/5/13
to Robotium Developers
What happens if you do this:

solo = new Solo(getInstrumentation());
getActivity();

/Renas


On Jun 5, 8:17 pm, CG <slide...@gmail.com> wrote:
> Thanks for the suggestion.  Unfortunately neither of those work.  Even
> though I can see the new activity on the screen, if I call waitForActivity
> it will return false and assertCurrentActivity indicates it is still on my
> initial activity (Profile) and has not gone to the new activity (Login).
> Even though I see Login when the tests starts, I get these results:
>
> junit.framework.ComparisonFailure: Not on login screen
> expected:<....activities.[Login]> but was:<....activities.[Profile]>
> at
> com.jayway.android.robotium.solo.Asserter.assertCurrentActivity(Asserter.ja va:55)
> at
> com.jayway.android.robotium.solo.Solo.assertCurrentActivity(Solo.java:602)
> ...
>
> Here is a scaled down version of the test.
>
> package com.zzz.activities.test;
> import android.test.ActivityInstrumentationTestCase2;
> import com.jayway.android.robotium.solo.Solo;
> import com.zzz.activities.Login;
> import com.zzz.activities.Profile;
>
> public class LoginTest2 extends ActivityInstrumentationTestCase2<Profile> {
>
> private Solo solo;
>
> public LoginTest2() {
>
> super(Profile.class);
>
> }
>
> protected void setUp() throws Exception {
>
> super.setUp();
>
> solo = new Solo(getInstrumentation(), getActivity());
>
> }
>
> public void testSigninButton() {
>
> solo.sleep(3000);
>
> solo.waitForActivity(Login.class, 15000);
>
> solo.assertCurrentActivity("Not on login screen", Login.class);
>
> }
>
> protected void tearDown() throws Exception {
>
> solo.finishOpenedActivities();
>
>
>
>
>
>
>
> }
> }
> On Monday, June 3, 2013 9:26:32 PM UTC-7, Renas Reda wrote:
>
> > Hi,
>
> > Use waitForActivity or assertCurrentActivity.
>
> > /Renas
> > On 4 Jun 2013 06:25, "CG" <slid...@gmail.com <javascript:>> wrote:
>
> >> I'm trying to get started with Robotium.  I figured our login page would
> >> be a good place to start.  This is the way our login page currently works:
>
> >> 1) Start the UserProfile activity
> >> 2) If user is not logged, start the Login activity
> >> 3) User enters login criteria, clicks log in.  This logs the user in and
> >> finishes the Login activity, returning to Profile
>
> >> I'd like to test that the user's click on the login button correctly logs
> >> the user in and returns to the Profile activity.  To do this I based my
> >> test on the UserProfile activity.  However I can't get my test case to
> >> recognize that the activity has changed from UserProfile to Login.  The
> >> posts I've seen suggest that I should base my test on the Login activity.
> >>  This works fine until the user clicks login and the activity finishes with
> >> nowhere to return to.
>
> >> Any suggestions for how I can get this to work in Robotium?
>
> >> Thanks!
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Robotium Developers" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an
> >> email to robotium-develo...@googlegroups.com <javascript:>.
> >> To post to this group, send email to robotium-...@googlegroups.com<javascript:>
> >> .

Renas

unread,
Jun 5, 2013, 10:19:20 PM6/5/13
to robotium-...@googlegroups.com
Based on you not being able to find the button on the login page makes me believe that it belongs to another process. Please see Q&A:


/Renas


On Wed, Jun 5, 2013 at 9:27 PM, CG <slid...@gmail.com> wrote:

If I change my test method as below, it's still not working.  I'm still getting the Profile class when I call getActivity, and it fails to find my button that is on the Login page.  Oddly, in this case both waitForActivity and assertCurrentActivity hang when called after the getting the new Solo object and calling getActivity().

public void testSigninButton() {

try {

Thread.sleep(3000);

} catch( Exception ex ) {

}


solo = new Solo(getInstrumentation());

String s = getActivity().getClass().getName();

Log.d("LoginTest2", "Activity after new Solo: " + s);


Button signin = (Button) solo.getView(R.id.zzz_signin);

solo.clickOnView(signin);

//solo.waitForActivity(Login.class, 15000);

//solo.assertCurrentActivity("Not on login screen", Login.class);

}

> >> email to robotium-developers+unsub...@googlegroups.com <javascript:>.
> >> To post to this group, send email to robotium-...@googlegroups.com<javascript:>
> >> .
> >> Visit this group at
> >>http://groups.google.com/group/robotium-developers?hl=en.
> >> For more options, visithttps://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotium-develo...@googlegroups.com.
To post to this group, send email to robotium-...@googlegroups.com.

Renas

unread,
Jun 6, 2013, 6:36:25 PM6/6/13
to robotium-...@googlegroups.com

Please submit this issue in the issue tracker.

/Renas

On 6 Jun 2013 15:34, "CG" <slid...@gmail.com> wrote:
Thanks, appreciate the quick responses.   The activity is definitely in the same process.  It seems the reason it can't find the button is that solo never gets initialized to the new activity.  

Activity A (Profile) starts, immediately starts activity B (Login) then B finishes and returns to A.  My test never seems to see activity B.  I can't start the test on activity B since when it finishes I want to confirm that it returns to activity A.  
> >> To post to this group, send email to robotium-...@googlegroups.com<javascript:>
> >> .
> >> Visit this group at
> >>http://groups.google.com/group/robotium-developers?hl=en.
> >> For more options, visithttps://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotium-developers+unsub...@googlegroups.com.

To post to this group, send email to robotium-...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotium-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

naveed

unread,
Jun 7, 2013, 2:33:55 AM6/7/13
to robotium-...@googlegroups.com
If this is the case,
"The activity is definitely in the same process.  It seems the reason it can't find the button is that solo never gets initialized to the new activity.  "
it should definitely work, can you please give me app name if possible, I would love to see it.


On Friday, June 7, 2013 2:31:06 AM UTC+5, CG wrote:
Thanks, appreciate the quick responses.   The activity is definitely in the same process.  It seems the reason it can't find the button is that solo never gets initialized to the new activity.  

Activity A (Profile) starts, immediately starts activity B (Login) then B finishes and returns to A.  My test never seems to see activity B.  I can't start the test on activity B since when it finishes I want to confirm that it returns to activity A.  

> >> To post to this group, send email to robotium-...@googlegroups.com<javascript:>
> >> .
> >> Visit this group at
> >>http://groups.google.com/group/robotium-developers?hl=en.
> >> For more options, visithttps://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotium-developers+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages