2017-02-21 12 views
0

私はエスプレッソを使用して私のアプリの計測器テストを書いていますが、問題が発生しました。私のテストでAndroidスタジオはクリックしないでください

私は私のサインアップ]ボタンをクリックしてください

私は、私はエラーが供給された onViewを使用したときのよう onDataonViewから変更

android.support.test.espresso.PerformException: Error performing 'load adapter data' on view 'is assignable from class: class android.widget.AdapterView'. 

エラーを取得

onData(withId(R.id.signUpButton)).perform(click()); 

メッセージ

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: uk.co.vouchercodes.android.beta:id/signUpButton If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:android.widget.GridView{5c810ee VFED..C.. ........ 0,0-1080,1376 #7f1001f0 app:id/onboardingMerchantGridView}

誰も同じような問題を経験しましたか?この問題の周りの最善の方法は何ですか?

おかげ XML

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:clickable="true" 
    android:background="@color/vc_green_5_onboarding" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<ProgressBar 
     android:id="@+id/progressBar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:visibility="invisible"/> 

<ScrollView 
     android:id="@+id/authScrollView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <LinearLayout 
      style="@style/PaddedLayout" 
      android:orientation="vertical"> 

     <TextView 
       android:id="@+id/authTitleTextView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       tools:text="AUTH TITLE" 
       android:layout_marginTop="@dimen/margin_top" 
       android:textStyle="bold" 
       android:gravity="center" 
       android:layout_marginBottom="@dimen/spacing_standard"/> 

     <LinearLayout 
       android:id="@+id/signupContentLayout1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

      <ImageView 
        android:layout_width="@dimen/spacing_double" 
        android:layout_height="match_parent" 
        android:layout_marginRight="@dimen/spacing_standard" 
        android:src="@drawable/name_icon" 
        android:scaleType="fitStart" 
        android:tint="@color/white"/> 

      <EditText 
        android:id="@+id/nameField" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:hint="@string/name" 
        android:textColorHint="@color/white" 
        android:paddingBottom="@dimen/spacing_half" 
        android:layout_marginBottom="@dimen/spacing_standard" 
        android:background="@drawable/authorization_edittext" 
        android:inputType="textCapWords|textPersonName" 
        android:singleLine="true"/> 
     </LinearLayout> 

     <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

      <ImageView 
        android:layout_width="@dimen/spacing_double" 
        android:layout_height="match_parent" 
        android:layout_marginRight="@dimen/spacing_standard" 
        android:src="@drawable/email_icon" 
        android:scaleType="fitStart" 
        android:tint="@color/white"/> 

      <AutoCompleteTextView 
        android:id="@+id/emailField" 
        android:layout_width="0px" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:hint="@string/email" 
        android:textColorHint="@color/white" 
        android:paddingBottom="@dimen/spacing_half" 
        android:layout_marginBottom="@dimen/spacing_standard" 
        android:background="@drawable/authorization_edittext" 
        android:imeOptions="actionNext" 
        android:inputType="textEmailAddress" 
        android:singleLine="true"/> 

     </LinearLayout> 

     <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

      <ImageView 
        android:id="@+id/passwordLabel" 
        android:layout_width="@dimen/spacing_double" 
        android:layout_height="match_parent" 
        android:layout_marginRight="@dimen/spacing_standard" 
        android:src="@drawable/password_icon" 
        android:scaleType="fitStart" 
        android:tint="@color/white"/> 

      <EditText 
        android:id="@+id/passwordField" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:hint="@string/password" 
        android:textColorHint="@color/white" 
        android:paddingBottom="@dimen/spacing_half" 
        android:layout_marginBottom="@dimen/spacing_standard" 
        android:background="@drawable/authorization_edittext" 
        android:inputType="textPassword" 
        android:singleLine="true"/> 
     </LinearLayout> 

     <TextView 
       android:id="@+id/forgotPasswordText" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/forgot_password" 
       android:background="@android:color/transparent" 
       android:gravity="center" 
       android:paddingBottom="10dp"/> 

     <Button 
       android:id="@+id/signButton" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="@string/sign_up" 
       android:layout_marginTop="@dimen/spacing_standard" 
       android:background="@drawable/btn_auth_white_stroke"/> 

     <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="@string/onboarding_or" 
       android:textStyle="bold" 
       android:layout_margin="@dimen/margin_top"/> 

     <Button 
       android:id="@+id/facebookButton" 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/onboarding_button_height" 
       android:text="@string/facebook_connect" 
       android:layout_gravity="center" 
       android:background="@drawable/btn_facebook_background" 
       android:paddingLeft="40dp"/> 

     <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center"> 

      <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/icon_padlock" 
        android:padding="4dp"/> 

      <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/facebook_no_post" 
        android:textSize="@dimen/text_size_small" 
        android:textStyle="bold" 
        android:padding="4dp"/> 

     </LinearLayout> 

     <TextView 
       android:id="@+id/switchTextView" 
       android:layout_width="@dimen/onboarding_privacy_and_terms_width" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="@dimen/margin_top" 
       android:text="@string/auth_switch_to_signin" 
       android:layout_gravity="center" 
       android:textSize="@dimen/onboarding_text_size_pin" 
       android:textStyle="bold" 
       android:gravity="center"/> 

     <TextView 
       android:id="@+id/privacyTermsText" 
       android:layout_width="@dimen/onboarding_privacy_and_terms_width" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="@dimen/margin_top" 
       android:layout_gravity="center" 
       android:textSize="@dimen/text_size_small" 
       android:textStyle="bold" 
       android:gravity="center" 
       tools:text="@string/auth_privacy_terms" 
       android:layout_marginBottom="@dimen/spacing_standard"/> 

    </LinearLayout> 

</ScrollView> 

+0

あなたは 'onView'を使用して、テストを実行するときにボタンが存在しない理由を理解してください。 –

+0

@bartekLipinskiこのエラーが発生しました。'ターゲットビューが1つ以上と一致しないためにアクションが実行されません次の制約のうち ビューの領域の少なくとも90%がユーザーに表示されます。 –

+0

はい、正確に把握する必要があります。エスプレッソ・テストを開始すると、このボタンが表示されますか? –

答えて

0

あなたはonViewメソッドを使用する必要があります。あなたの問題は、間違ったIDを使用していることです。 signButtonという名前のボタンを定義しましたが、signUpButtonという名前のボタンを使用しているため、エラーが発生します。

関連する問題