无法使用Espresso将文本添加到Webview文本字段 [英] Cant add text to webview text field with Espresso

查看:121
本文介绍了无法使用Espresso将文本添加到Webview文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Esprsso中将文本添加到文本字段(在Webview中),并且出现此错误:

I am trying to add text to a textfield (inside a webview) in Esprsso and I'm getting this error:

原因:java.lang.RuntimeException:评估错误评估: 状态:13值:{message =无法设置选择结束} hasMessage: 真实消息:无法设置选择结束

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("exmaple@test.com"));

当我只是单击文本字段时,它会起作用,但是当我尝试输入文本时,它会崩溃.

when i'm just clicking on the textfield it works but when i'm trying to enter text it crashes.

推荐答案

我正面临着同样的问题.我的代码适用于Android 7.1.1模拟器,但在Android 8.0模拟器上失败. 我通过在build.gradle中执行以下操作来解决它.

I am facing the same issue. My code works for Android 7.1.1 simulator but it fails on the Android 8.0 simulator. I got it resolved by doing the following in the build.gradle.

1)升级浓缩咖啡库. 我在:

1) Upgrade espresso library. I was on:

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)完成此操作后,您的应用可能无法构建.可能会说找不到test:runner:1.0.0 在这种情况下,您需要添加

2) After doing that, your app might not build. It might say it cannot find the test:runner:1.0.0 In that case, you need to add

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

3)您可能需要解决的以下问题是,它可能会抱怨应用程序(2x.x.x)和测试应用程序(2x.x.x)的版本不同" 因此,我将以下内容添加到了gradle中.

3) The following issue you might need to resolve is that it might complain about "versions for app (2x.x.x) and test app (2x.x.x) differ" So I add the following in the gradle.

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

4)另外,您可能需要确保已添加跑步者".

4) Additional, you might need to make sure you have the Runner added.

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

这篇关于无法使用Espresso将文本添加到Webview文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆