나는 Espresso를 사용하여 내 응용 프로그램에 대한 계측 테스트를 작성하기 시작했으나 문제가 발생했습니다. 내 테스트에Android studio 클릭 수행하지 않음
내가 가입 버튼을 클릭하려고
나는 내가 오류를 잡되었다onView
를 사용하는 경우로
onData
에
onView
변경
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>
당신은'onView'를 사용해야하고 테스트를 실행할 때 버튼이없는 이유를 알아 내야합니다. –
@bartekLipinski이 오류가 발생했습니다.'대상 뷰가 하나 이상의 타겟과 일치하지 않기 때문에 작업이 수행되지 않습니다 다음과 같은 제약 조건이 있습니다 : 보기 영역의 90 % 이상이 사용자에게 표시됩니다. ' –
예, 정확히 알아 내야합니다. 에스프레소 테스트를 시작할 때이 버튼이 보이십니까? –