小编Sar*_*ara的帖子

WebView 自动填充被禁用,因为 WebView 不是使用活动上下文创建的

独立于我保留此日志的解决方案:

W/cr_AwAutofillManager: WebView autofill is disabled because WebView isn't created with activity context.

  1. 为什么会出现这个日志?我在网上找不到任何这样的例子。
  2. 有没有办法解决这个问题/使用没有javascript的自动填充?

我对 android 没有太多经验,我尝试了一些调整,例如调用 setImportantForAutofill() 和 setAutofillHints 以及其他引用自动填充的方法调用。

LoginApplication.java (扩展 AppCompatActivity )

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MainApplication.getMyComponent().inject(this);

        setContentView(R.layout.activity_login);
        WebView loginWebView = findViewById(R.id.weblogin);

        loginWebView.setWebViewClient(new CustomWebClient(storage, keycloakService, this));
        WebSettings webSettings = loginWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportMultipleWindows(true);
        loginWebView.loadUrl(authCodeUrl.toString());
    }
Run Code Online (Sandbox Code Playgroud)

activity_login.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".auth.LoginApplication">

    <WebView
        android:id="@+id/weblogin"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

部分 AndroidManifest.xml


        <activity
            android:name=".auth.LoginApplication">
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" /> …
Run Code Online (Sandbox Code Playgroud)

java android android-webview

10
推荐指数
0
解决办法
2240
查看次数

黄瓜测试不读取cucumber.properties 文件

我使用 Junit5 和 Cucumber 创建了一个小片段 Spring Boot 应用程序。因为我需要使用 Junit5 我正在使用cucumber-junit-platform-engine它不支持注释CucumberOptions

正如在cucumber.io 网站上引用的:

当运行程序(即cucumber-junit-platform-engine)不提供属性解析功能时,Cucumber 将按优先级从系统属性、环境变量和cucumber.properties 文件中解析属性。

因此,我将以下文件添加cucumber.properties到我的目录中src/test/resources,内容如下:

cucumber.plugin=json:target/cucumber-reports/,pretty
Run Code Online (Sandbox Code Playgroud)

然而,当我运行我的测试时,这个文件似乎被忽略了,因为如果我通过 cli 参数传递相同的属性,则不会生成任何报告,例如:

mvn test -Dcucumber.plugin=json:target/cucumber-reports/,pretty 它生成预期的 json 报告。

我也尝试将文件放在src/main/resources下面src/main/test/cucumber.demo(功能文件所在的位置),但这些尝试都没有奏效。知道为什么文件被忽略了吗?

这是我的跑步者课程:

cucumber.plugin=json:target/cucumber-reports/,pretty
Run Code Online (Sandbox Code Playgroud)

和我的步骤定义类:

@Cucumber
public class CucumberTest {
    
}
Run Code Online (Sandbox Code Playgroud)

java testing junit cucumber junit5

2
推荐指数
1
解决办法
2091
查看次数

标签 统计

java ×2

android ×1

android-webview ×1

cucumber ×1

junit ×1

junit5 ×1

testing ×1