2017-08-08 81 views
0

我試圖在Esprsso文本添加到文本框(網頁視圖內),我得到這個錯誤:不能添加文本的WebView文本字段與咖啡

Caused by: java.lang.RuntimeException: Error in evaluationEvaluation: status: 13 value: {message=Cannot set the selection end} hasMessage: true message: Cannot set the selection end

代碼:

textField.perform(webKeys("[email protected]")); 

當我剛一下它的工作文本框,但是當我試圖進入它崩潰文本。

+0

你找到答案嗎?我一直面臨同樣的問題! :( – dira

回答

0

我面臨着同樣的問題。我的代碼適用於Android 7.1.1模擬器,但在Android 8.0模擬器上失敗。 我通過在build.gradle中執行以下操作來解決問題。

1)升級咖啡文庫。 我是:

androidTestCompile 'com.android.support.test:runner:0.5' 
androidTestCompile 'com.android.support.test:rules:0.5' 
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') 

現在到:

androidTestCompile 'com.android.support.test:runner:1.0.0' 
androidTestCompile 'com.android.support.test:rules:1.0.0' 
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0' 
androidTestCompile('com.android.support.test.espresso:espresso-contrib:3.0.0') 

2)這樣做之後,你的應用程序可能無法建立。它可能會說這是不可能找到測試:亞軍:1.0.0 在這種情況下,你需要添加

repositories { 
    maven { url "https://maven.google.com" } 
} 

3)您可能需要解決以下的問題是,它可能會抱怨「版本的應用程序(2x.xx)和測試應用程序(2x.xx)不同「 因此,我在gradle中添加以下內容。

configurations.all { 
    resolutionStrategy.force 'com.android.support:support-annotations:2x.x.x' 
} 

4)另外,您可能需要確保您已添加Runner。

defaultConfig { 
     "android.support.test.runner.AndroidJUnitRunner" 
}