不断得到错误" HTTPClient :: ReceiveTimeoutError"用我非常简单的葫芦测试案例

时间:2016-08-26 14:31:04

标签: android cucumber calabash calabash-android

我是calabash-android测试自动化库中的新手。我花了两天时间来理解这个问题并没有成功:(

我正在使用calabash-android 版本0.8.0 ,我按照记录的pre-defined steps进行测试。

我的测试很简单,只需等待登录屏幕(这是一个包含id" email_field")的输入字段的活动,输入用户名和密码。以下是我在功能文件中的步骤:

Feature: Login feature
Scenario: As a user I can login
    Then I wait for the view with id "email_field" to appear
    Then I enter text "john123@gmail.com" into field with id "email_field"
    Then I enter text "123456" into field with id "pwd_field"

当我使用命令calabash-android run myApp.apk运行我的测试时,我的应用程序已启动,显示登录屏幕,但过了一段时间,我的应用程序已关闭&我经常获得以下错误,无论在哪个Android设备上运行(在Android 4.3和Android 6.0设备上测试):

Feature: Login feature

  Scenario: As a user I can login                                        # features/my_first.feature:2
  execution expired (HTTPClient::ReceiveTimeoutError)
  ./features/support/app_life_cycle_hooks.rb:5:in `Before'
    Then I wait for the view with id "email_field" to appear           # calabash-android-0.8.0/lib/calabash-android/steps/progress_steps.rb:42
    Then I enter text "john123@gmail.com" into field with id "email_field" # calabash-android-0.8.0/lib/calabash-android/steps/enter_text_steps.rb:13
    Then I enter text "123456" into field with id "pwd_field"     # calabash-android-0.8.0/lib/calabash-android/steps/enter_text_steps.rb:13

Failing Scenarios:
cucumber features/my_first.feature:2 # Scenario: As a user I can login

1 scenario (1 failed)
3 steps (3 skipped)
0m34.567s

为什么呢? (在我的AndroidManifest.xml中,我有<uses-permission android:name="android.permission.INTERNET" /><uses-sdk android:targetSdkVersion="22" />

=== calabash-android console ===

的更多信息

我也启动了calabash-android console,并运行命令start_test_server_in_background,我得到以下错误stacktrace

calabash-android console myApp.apk 
Starting calabash-android console...
Loading /Users/John/.rvm/gems/ruby-2.3.0/gems/calabash-android-0.8.0/irbrc
Running irb...
irb(main):001:0> start_test_server_in_background
HTTPClient::ReceiveTimeoutError: execution expired
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient/session.rb:799:in `gets'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient/session.rb:799:in `block in parse_header'
    from /Users/John/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient/session.rb:795:in `parse_header'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient/session.rb:778:in `read_header'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient/session.rb:554:in `get_header'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient.rb:1297:in `do_get_header'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient.rb:1243:in `do_get_block'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient.rb:1017:in `block in do_request'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient.rb:1131:in `protect_keep_alive_disconnected'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient.rb:1012:in `do_request'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient.rb:854:in `request'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/httpclient-2.8.2.2/lib/httpclient.rb:763:in `post'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/calabash-android-0.8.0/lib/calabash-android/operations.rb:500:in `make_http_request'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/calabash-android-0.8.0/lib/calabash-android/operations.rb:437:in `http'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/calabash-android-0.8.0/lib/calabash-android/operations.rb:752:in `start_application'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/calabash-android-0.8.0/lib/calabash-android/operations.rb:743:in `start_test_server_in_background'
    from /Users/John/.rvm/gems/ruby-2.3.0/gems/calabash-android-0.8.0/lib/calabash-android/operations.rb:143:in `start_test_server_in_background'
    from (irb):1
    from /Users/John/.rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'irb(main):002:0> 

=======尝试@ Tobias&#39;通过将DEBUG_HTTP标志设置为true来建议=========

我试过 @Tobias &#39;建议,通过执行命令calabash-android run myApp.apk DEBUG=1 DEBUG_HTTP=1,这里是输出(在底部是相同的错误消息):

No test server found for this combination of app and calabash version. Recreating test server.
Done signing the test server. Moved it to test_servers/b813b6bcf17675e303e5cb7f53c2a85f_0.8.0.apk
DEBUG: Setting Android SDK location to $ANDROID_HOME
DEBUG: Android SDK location set to '/Users/John/Library/Android/sdk'
DEBUG: Set aapt path to '/Users/John/Library/Android/sdk/build-tools/23.0.3/aapt'
DEBUG: Set zipalign path to '/Users/John/Library/Android/sdk/build-tools/23.0.3/zipalign'
DEBUG: Set adb path to '/Users/John/Library/Android/sdk/platform-tools/adb'
DEBUG: Set android jar path to '/Users/John/Library/Android/sdk/platforms/android-24/android.jar'
DEBUG: Setting Java SDK location to $JAVA_HOME
DEBUG: Java SDK location set to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home'
DEBUG: Found java on PATH
DEBUG: Set java path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java'
DEBUG: Found keytool on PATH
DEBUG: Set keytool path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/keytool'
DEBUG: Found jarsigner on PATH
DEBUG: Set jarsigner path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/jarsigner'
Feature: Login with email and password

= Request

! CONNECT TO 127.0.0.1:34777
! CONNECTION ESTABLISHED
POST //ping HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: HTTPClient/1.0 (2.8.2.2, ruby 2.3.0 (2015-12-25))
Accept: */*
Date: Sun, 28 Aug 2016 15:57:34 GMT
Content-Length: 2
Host: 127.0.0.1:34777

{}

= Response

! CONNECTION CLOSED
= Request

! CONNECT TO 127.0.0.1:34777
! CONNECTION ESTABLISHED
POST //ping HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: HTTPClient/1.0 (2.8.2.2, ruby 2.3.0 (2015-12-25))
Accept: */*
Date: Sun, 28 Aug 2016 15:57:34 GMT
Content-Length: 2
Host: 127.0.0.1:34777

{}

= Response

! CONNECTION CLOSED
= Request

! CONNECT TO 127.0.0.1:34777
! CONNECTION ESTABLISHED
POST //ping HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: HTTPClient/1.0 (2.8.2.2, ruby 2.3.0 (2015-12-25))
Accept: */*
Date: Sun, 28 Aug 2016 15:57:34 GMT
Content-Length: 2
Host: 127.0.0.1:34777

{}

= Response

HTTP/1.0 200 OK 
Content-Type: text/html
Date: Sun, 28 Aug 2016 15:57:35 GMT

pong! CONNECTION CLOSED
= Request

! CONNECT TO 127.0.0.1:34777
! CONNECTION ESTABLISHED
POST //ping HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: HTTPClient/1.0 (2.8.2.2, ruby 2.3.0 (2015-12-25))
Accept: */*
Date: Sun, 28 Aug 2016 15:57:34 GMT
Content-Length: 2
Host: 127.0.0.1:34777

{}

= Response

HTTP/1.0 200 OK 
Content-Type: text/html
Date: Sun, 28 Aug 2016 15:57:35 GMT

pong! CONNECTION CLOSED
= Request

! CONNECT TO 127.0.0.1:34777
! CONNECTION ESTABLISHED
POST //ready HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: HTTPClient/1.0 (2.8.2.2, ruby 2.3.0 (2015-12-25))
Accept: */*
Date: Sun, 28 Aug 2016 15:57:34 GMT
Content-Length: 2
Host: 127.0.0.1:34777

{}

= Response

HTTP/1.0 200 OK 
Content-Type: text/html
Date: Sun, 28 Aug 2016 15:57:35 GMT

true! CONNECTION CLOSED
= Request

! CONNECT TO 127.0.0.1:34777
! CONNECTION ESTABLISHED
POST // HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: HTTPClient/1.0 (2.8.2.2, ruby 2.3.0 (2015-12-25))
Accept: */*
Date: Sun, 28 Aug 2016 15:57:34 GMT
Content-Length: 36
Host: 127.0.0.1:34777

{"command":"version","arguments":[]}

= Response

HTTP/1.0 200 OK 
Content-Type: text/html
Date: Sun, 28 Aug 2016 15:57:35 GMT

{"bonusInformation":[],"message":"0.8.0","success":true}! CONNECTION CLOSED
= Request

! CONNECT TO 127.0.0.1:34777
! CONNECTION ESTABLISHED
POST //start-application HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: HTTPClient/1.0 (2.8.2.2, ruby 2.3.0 (2015-12-25))
Accept: */*
Date: Sun, 28 Aug 2016 15:57:35 GMT
Content-Length: 15
Host: 127.0.0.1:34777

{"intent":null}

= Response

! CONNECTION CLOSED
  Scenario: As a user I can login                                        # features/my_first.feature:3
        Then I wait for the view with id "email_field" to appear
  execution expired (HTTPClient::ReceiveTimeoutError)
  ./features/support/app_life_cycle_hooks.rb:5:in `Before'
    Then I enter text "john123@gmail.com" into field with id "account_input" # calabash-android-0.8.0/lib/calabash-android/steps/enter_text_steps.rb:13
    Then I enter text "123456" into field with id "password_input"     # calabash-android-0.8.0/lib/calabash-android/steps/enter_text_steps.rb:13

顺便说一句,关于功能文件的第一步,即Then I wait for the view with id "email_field" to appear。 &#34; email_field&#34;在登录活动中。在主要活动中完成某些操作后,我从主要活动开始登录活动。看起来失败是第一步。

===== Logcat日志====

这是logcat日志,我无法弄清楚它如何帮助解决我的问题。

08-29 10:54:14.892 13474 13474 I calabash: execStartActivity 4
08-29 10:54:14.892 13474 13474 I Timeline: Timeline: Activity_launch_request id:com.john.myApp time:50467579
08-29 10:54:14.893   956  3893 I ActivityManager: START u0 {cmp=com.john.myApp/.LoginActivity (has extras)} from uid 10627 on display 0
08-29 10:54:14.917 13474 13474 I mainui  : onPause
08-29 10:54:14.927 13474 13474 I calabash: newActivity1
08-29 10:54:15.018   956  1025 I ActivityManager: Displayed com.john.myApp/.LoginActivity: +100ms (total +7s320ms)
08-29 10:54:15.271   956  1025 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{99dcb96 u0 com.john.myApp/.LoginActivity t14253} time:50467958
08-29 10:54:16.084   956  1003 W ActivityManager: Launch timeout has expired, giving up wake lock!
08-29 10:54:16.103 13089 13144 W FlurryAgent: Flurry session paused for context:com.estrongs.android.pop.app.InstallMonitorActivity@bb5ddc9
08-29 10:54:18.546  4723  4723 I Auth    : [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
08-29 10:54:18.547  4723  4723 I Auth    : [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
08-29 10:54:18.572  4723  4723 I Auth    : [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
08-29 10:54:18.897 13501 13550 W Flag    : Duration spec must be at least 2 characters long: 
08-29 10:54:18.897 13501 13550 W Flag    : Duration spec must be at least 2 characters long: 
08-29 10:54:19.232 13501 13550 W linker  : /data/app/com.google.android.gms-2/lib/arm/libgmscore.so: unused DT entry: type 0x7ffffffd arg 0xa74
08-29 10:54:19.252 13501 13550 W linker  : /data/app/com.google.android.gms-2/lib/arm/libconscrypt_gmscore_jni.so: unused DT entry: type 0x1d arg 0xe0
08-29 10:54:19.252 13501 13550 W linker  : /data/app/com.google.android.gms-2/lib/arm/libconscrypt_gmscore_jni.so: unused DT entry: type 0x7ffffffd arg 0x1cb
08-29 10:54:19.263 13501 13550 V JNIHelp : Registering com/google/android/gms/org/conscrypt/NativeCrypto's 255 native methods...
08-29 10:54:19.282   469   469 I Gobi    : vendor/qcom/proprietary/RIDL/RIDLClient/RIDLSQL.cpp:2500: GetTransState() EBADF
08-29 10:54:19.282   469   469 I Gobi    : vendor/qcom/proprietary/RIDL/RIDLClient/MainCore.cpp:1550: Failed to get TransState, rc 9
08-29 10:54:19.283   469   469 I Gobi    : vendor/qcom/proprietary/RIDL/RIDLClient/RIDLSQL.cpp:2500: GetTransState() EBADF
08-29 10:54:19.283   469   469 I Gobi    : vendor/qcom/proprietary/RIDL/RIDLClient/RIDLSQL.cpp:2500: GetTransState() EBADF
08-29 10:54:19.357 13501 13550 I ProviderInstaller: Installed default security provider GmsCore_OpenSSL
08-29 10:54:20.615 13415 13448 I Finsky  : [6145] com.google.android.finsky.c.e.run(1154): Replicating app states via AMAS.
08-29 10:54:21.049 13415 13448 I Finsky  : [6145] com.google.android.finsky.c.c.a(316): Completed 0 account content syncs with 0 successful.
08-29 10:54:21.064 13415 13415 I Finsky  : [1] com.google.android.finsky.services.j.a(149): Installation state replication succeeded.
08-29 10:54:21.575   956  3287 I ActivityManager: Start proc 13734:com.joelapenna.foursquared/u0a427 for broadcast com.joelapenna.foursquared/com.foursquare.pilgrim.app.service.ReceiverPilgrimLocationClientFire
08-29 10:54:21.654 13734 13734 W System  : ClassLoader referenced unknown path: /data/app/com.joelapenna.foursquared-2/lib/arm
08-29 10:54:21.675 13734 13734 I MultiDex: VM with version 2.1.0 has multidex support
08-29 10:54:21.675 13734 13734 I MultiDex: install
08-29 10:54:21.675 13734 13734 I MultiDex: VM has multidex support, MultiDex support library is disabled.
08-29 10:54:21.682 13734 13734 I FirebaseInitProvider: FirebaseApp initialization unsuccessful
08-29 10:54:21.820 13734 13734 I Fabric  : Initializing Crashlytics 2.3.2.56
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: com.google.android.gms signature not valid.  Found: 
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: PYtRmasflljsAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: AASWEQIEwpDYWxpZmurksngexorhlpquflseknvaseudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29n
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: kIVXXCdjLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEz
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: QAMSDfw0zNjAxMDcydfgawelhsdrgrAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYw
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: PPUTIFHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5k
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtW
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: LgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKke
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: xfaLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: dfaGEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/Cx
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: UsfhBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJE
08-29 10:54:21.833 13734 13755 V GoogleSignatureVerifier: jsef//0zOOIBRiGYXtqw/A0LFFoiinblsdrgsQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/T

08-29 10:54:22.095 13734 13734 D BeaconParser: Parsing beacon layout: m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25
08-29 10:54:22.096 13734 13734 D BeaconParser: Parsing beacon layout: m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24
08-29 10:54:22.098 13734 13734 D BeaconParser: Parsing beacon layout: s:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-13,i:14-19
08-29 10:54:22.099 13734 13734 D BeaconParser: Parsing beacon layout: s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-20v
08-29 10:54:22.139 13734 13770 W System  : ClassLoader referenced unknown path: /system/framework/tcmclient.jar
08-29 10:54:22.225 13734 13734 D AppsFlyer_4.5.0: Build Number: 138
08-29 10:54:23.776 13474 13806 I System.out: URI: //kill
08-29 10:54:23.777 13474 13806 I System.out: params: {json={}
08-29 10:54:23.777 13474 13806 I System.out: }
08-29 10:54:23.777 13474 13806 I System.out: Stopping test server
08-29 10:54:23.785   956  3256 W ActivityManager: Duplicate finish request for ActivityRecord{5c6dbdd u0 com.john.myApp/.MainActivity t14253 f}
08-29 10:54:23.786   956  3177 W ActivityManager: Duplicate finish request for ActivityRecord{5c6dbdd u0 com.john.myApp/.MainActivity t14253 f}
08-29 10:54:23.789 13474 13474 I mainui  : onStop
08-29 10:54:23.813 13474 13474 I Timeline: Timeline: Activity_idle id: android.os.BinderProxy@e70b6f8 time:50476500
08-29 10:54:23.831   956   977 W ActivityManager: Finishing task with all activities already finished
08-29 10:54:23.831   956   977 W ActivityManager: Duplicate finish request for ActivityRecord{99dcb96 u0 com.john.myApp/.LoginActivity t14253 f}
08-29 10:54:23.894  3847  3847 I Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2efe322 time:50476582
08-29 10:54:24.023   956  1025 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{36601a6 u0 com.sonyericsson.home/com.sonymobile.home.HomeActivity t14213} time:50476710
08-29 10:54:26.154 13089 13144 W FlurryAgent: Flurry session ended

在上面的logcat日志中,值得注意的部分是:

08-29 10:54:23.776 13474 13806 I System.out: URI: //kill
08-29 10:54:23.777 13474 13806 I System.out: params: {json={}
08-29 10:54:23.777 13474 13806 I System.out: }
08-29 10:54:23.777 13474 13806 I System.out: Stopping test server

在另一台设备上运行我看到了:

W/ActivityManager(  869): Activity idle timeout for ActivityRecord{41cb4158 u0 com.john.myApp/.LoginActivity}
I/System.out( 8538): URI: //kill
I/System.out( 8538): params: {json={}
I/System.out( 8538): }
I/System.out( 8538): Stopping test server

当测试抛出calabash错误消息时:

execution expired (HTTPClient::ReceiveTimeoutError)
  ./features/support/app_life_cycle_hooks.rb:5:in `Before'

(为了澄清,登录活动是在测试期间启动的,但没有自动电子邮件和密码输入,应用程序随后关闭。)

无论如何,我仍然不知道logcat日志有什么问题。

1 个答案:

答案 0 :(得分:2)

将calabash-android降级为0.7.3解决了我的问题。